最近在仿造一個書城的網站: http://www.yousuu.com ,UI直接拿來用,前端后端自己寫,目前大部分功能已經實現,
就把具體的 登錄注冊功能 拿來分享一下。PS:又寫登錄注冊會不會被人噴啊=。=
一、開發環境的部署
程序結構:
BootStrap+Ajax+Struts2+Hibernate+MySql
僅供參考:能實現相關功能即可
操作系統:ubuntu 14.10
前端框架:BootStrap 注:此框架只是為了實現用戶界面,和具體功能無關
數據庫:mysql-5.5 數據庫工具:emma
服務器:tomcat 服務器工具:Myeclipse 10(已配置好Struts2和Hibernate環境)
注意:
程序調試過程可能會產生亂碼,只需保持所有工具編碼方式相同即可。
二、項目文件配置
1、新建Web Project,命名為ROOT
2、配置/WebRoot/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>ROOT</display-name> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/error.jsp</location> </error-page> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list></web-app>
3 、 配置/src/struts.xml(struts配置文件),其他的action和interceptor被我刪了,這點夠用了。
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts> <package name="default" namespace="/" extends="struts-default"> <!-- 登錄 --> <action name="login" class="com.action.Login" method="login"></action> <!-- 登出 --> <action name="logout" class="com.action.Logout" method="logout"></action> <!-- 注冊 --> <action name="register" class="com.action.Register" method="register"></action> <!-- 郵件發送 --> <action name="sendmail" class="com.action.SendMail" method="sendmail"></action> </package></struts>
新聞熱點
疑難解答
圖片精選