資源簡介
一個簡答的Web登錄程序基于struts2+Hibernate 方便struts2+Hibernate入門使用
代碼片段和文件信息
package?com.dream.action;
import?javax.servlet.http.HttpServletRequest;
import?org.apache.struts2.ServletActionContext;
import?com.dream.dao.UserDao;
import?com.opensymphony.xwork2.ActionSupport;
public?class?LoginAction?extends?ActionSupport{
/**Login登錄Action
?*?
?*/
private?static?final?long?serialVersionUID?=?1L;
public?String?execute()?throws?Exception?{
????????System.out.print(“有人登陸\n“);
????????HttpServletRequest?request?=?ServletActionContext.getRequest();
????????String?username?=?(String)?request.getParameter(“username“);
????????String?password?=?(String)?request.getParameter(“password“);
????????System.out.println(“賬號:“+username);
????????if?(username.isEmpty()?||?password.isEmpty()){
????????????return?ERROR;
????????}else?{
???????????if(new?UserDao().login(username?password))?{
???????? ???return?SUCCESS;
???????????}
???????????else?
???????????{
???????? ???return?ERROR;
???????????}
????????}
????}
}
評論
共有 條評論