首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

如何老是跳转request.setAttribute("msg" "用户名或密码错误,登录失败。");并且跳转到inde

2011-12-06 
怎么老是跳转request.setAttribute(msg, 用户名或密码错误,登录失败。),,,,,,并且跳转到index.jsp,怎

怎么老是跳转request.setAttribute("msg", "用户名或密码错误,登录失败。");,,,,,,并且跳转到index.jsp,怎么不跳啊,急
public ActionForward doLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException, ServletException {
// TODO Auto-generated method stub

request.getSession().removeAttribute("user");

String userName=request.getParameter("userName");
String userPwd=request.getParameter("userPwd");
User user=userBiz.login(userName,userPwd);
if(null!=user && user.getUserStatus()!=UserBiz.user_status_forbid)//登录成功
{
request.getSession().setAttribute("user", user);
if(user.getUserStatus()==UserBiz.user_status_admin)
{
//response.sendRedirect("admin.jsp");
//request.getRequestDispatcher("admin.jsp).forward(request, response);
//response.getWriter().println("<script language='javascript'>window.location.replace('admin.jsp');</script>");
return mapping.findForward("admin");
}else if(user.getUserStatus()==UserBiz.user_status_normal)
{
//response.sendRedirect("index.jsp");
return mapping.findForward("index");
}
}else
{
request.setAttribute("msg", "用户名或密码错误,登录失败。");
return mapping.findForward("index");
}
return null;
}

[解决办法]
if(null!=user && user.getUserStatus()!=UserBiz.user_status_forbid)//登录成功

这一句不成立,解决办法:
在他之前用
System.out.println(user);
System.out.println(user.getUserStatus());
看看是不是空,如果是空的话说明没收到数据,jsp页面估计有问题。自己试试吧

热点排行