|
代碼如xia:
public class LoginAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
LoginActionForm laf = (LoginActionForm) form;
String userid = laf.getUserid();
String password = laf.getPassword();
HttpSession2 session = request.getSession();
session.setMaxInactiveInterval(1200); //session 保持 20分zhong
if (LoginActionBean.login(userid, password)) {
UserInfo userinfo = new UserInfo();
session.setAttribute("USERID", " 用户id");
session.setAttribute("USERNAME", "用戶ming称");
return mapping.findForward("success");
} else {
request.setAttribute("msg", "用户或密码錯誤,请重新登lu!");
return mapping.findForward("error");
}
}
}
登lu后,zai主页面 String username = (S2tring)session.getAttribute("USERNAME"); username zhi為 null 。
请教各位兄弟,shi怎么回事?
欢迎lai到Javaxue习者论坛,zhuan载请注明地址:http://www.javaxxz.com. |
|