資源簡介
利用注解的方式,完成ssh(struts2、spring、hibernate)框架的搭建,并簡單的實(shí)現(xiàn)了注冊和登錄頁面
代碼片段和文件信息
package?com.ssh.action;
import?javax.annotation.Resource;
import?org.apache.struts2.convention.annotation.Action;
import?org.apache.struts2.convention.annotation.Namespace;
import?org.apache.struts2.convention.annotation.Result;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.stereotype.Controller;
import?com.opensymphony.xwork2.ActionSupport;
import?com.ssh.entity.User;
import?com.ssh.service.IUserService;
/**
?*?用戶控制器的實(shí)現(xiàn),判斷登錄的用戶名以及密碼是否存在
?*?@author?Administrator
?*
?*/
@Namespace(“/user“)
@Controller
public?class?UserAction?extends?ActionSupport?{
private?static?final?long?serialVersionUID?=?-6608326471441433394L;
@Resource
private?IUserService?iUserService;
private?User?user;
public?User?getUser()?{
return?user;
}
public?void?setUser(User?user)?{
this.user?=?user;
}
/**
?*?注冊新用戶
?*?@return
?*/
@Action(value=“regAction“results={
@Result(name=“regSuccess“l(fā)ocation=“/regSucc.jsp“)
@Result(name=“regFaile“l(fā)ocation=“/regFaile.jsp“)
})
public?String?register(){
System.out.println(“注冊id:?“+user.getId()?+“????注冊的用戶名:?“+user.getUserName()+“?????密碼:?“+user.getPassword());
iUserService.saveUser(user);
Boolean?check?=?iUserService.getUserByName(user.getUserName());
if(check){
System.out.println(“reg?seccess“);
return?“regSuccess“;
}else{
System.out.println(“reg?faile“);
return?“regFaile“;
}
}
/**
?*?檢查用戶登錄
?*?@return
?*/
@Action(value=“l(fā)oginAction“results={
@Result(name=“LoginSuccess“l(fā)ocation=“/loginSucc.jsp“)
@Result(name=“LoginFaile“l(fā)ocation=“/loginFaile.jsp“)
})
public?String?login(){
Boolean?check?=?iUserService.getUserByNameAndPassword(user);
if(check){
System.out.println(“l(fā)ogin?seccess“);
return?“LoginSuccess“;
}else{
System.out.println(“l(fā)ogin?faile“);
return?“LoginFaile“;
}
}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????834??2016-10-08?11:31??sshPro\.classpath
?????文件???????1039??2016-10-08?11:31??sshPro\.project
?????文件????????567??2016-10-08?11:31??sshPro\.settings\.jsdtscope
?????文件????????364??2016-10-08?11:31??sshPro\.settings\org.eclipse.jdt.core.prefs
?????文件????????470??2016-10-08?11:31??sshPro\.settings\org.eclipse.wst.common.component
?????文件????????345??2016-10-08?11:31??sshPro\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2016-10-08?11:31??sshPro\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2016-10-08?11:31??sshPro\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件???????2513??2016-10-09?17:19??sshPro\build\classes\com\ssh\action\UserAction.class
?????文件???????1963??2016-10-09?16:10??sshPro\build\classes\com\ssh\dao\impl\UserDao.class
?????文件????????265??2016-10-09?17:23??sshPro\build\classes\com\ssh\dao\IUserDao.class
?????文件???????1315??2016-10-09?17:23??sshPro\build\classes\com\ssh\entity\User.class
?????文件???????1066??2016-10-09?16:06??sshPro\build\classes\com\ssh\service\impl\UserService.class
?????文件????????277??2016-10-09?17:24??sshPro\build\classes\com\ssh\service\IUserService.class
?????文件???????2034??2016-10-09?17:19??sshPro\src\com\ssh\action\UserAction.java
?????文件???????1295??2016-10-09?16:10??sshPro\src\com\ssh\dao\impl\UserDao.java
?????文件????????383??2016-10-09?17:23??sshPro\src\com\ssh\dao\IUserDao.java
?????文件???????1040??2016-10-09?17:23??sshPro\src\com\ssh\entity\User.java
?????文件????????726??2016-10-09?16:06??sshPro\src\com\ssh\service\impl\UserService.java
?????文件????????391??2016-10-09?17:24??sshPro\src\com\ssh\service\IUserService.java
?????文件???????1376??2016-10-09?17:43??sshPro\WebContent\index.jsp
?????文件????????623??2016-10-09?15:14??sshPro\WebContent\loginFaile.jsp
?????文件????????623??2016-10-09?15:14??sshPro\WebContent\loginSucc.jsp
?????文件?????????39??2016-10-08?11:31??sshPro\WebContent\me
?????文件???????1240??2016-10-09?17:43??sshPro\WebContent\reg.jsp
?????文件????????623??2016-10-09?16:13??sshPro\WebContent\regFaile.jsp
?????文件????????623??2016-10-09?16:14??sshPro\WebContent\regSucc.jsp
?????文件???????2658??2016-10-09?14:52??sshPro\WebContent\WEB-INF\config\applicationContext.xm
?????文件????????314??2016-10-08?11:52??sshPro\WebContent\WEB-INF\config\sshDB.properties
?????文件????????870??2016-10-09?14:51??sshPro\WebContent\WEB-INF\config\struts.xm
............此處省略118個(gè)文件信息
評論
共有 條評論