「struts2」org.apache.struts2.ServletActionContextでrequest、responseとsessionを取得するコード

Javaコード

public class UserAction extends ActionSupport {
private HttpServletRequest req;
public String login() {
req = ServletActionContext.getRequest();
user = new User();
user.setUid(uid);
user.setPassword(password);
if (userDAO.isLogin(user)) {
req.getSession().setAttribute(“user", user);
return SUCCESS;
}
return LOGIN;
}
public String queryAll() {
req = ServletActionContext.getRequest();
uList = userDAO.queryAll();
req.getSession().setAttribute(“uList", uList);
return SUCCESS;
}
//some code
}

Java

Posted by arkgame