日期:2014-05-17 浏览次数:20675 次
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = request.getParameter("name"); String password = request.getParameter("password"); if(null == name || null == password || name.trim().equals("") || password.equals("")) { request.setAttribute("message", "请输入用户名和密码"); request.getRequestDispatcher("/index.jsp").forward(request, response); } if(name.equals(password)) { request.setAttribute("name", name); request.getRequestDispatcher("/welcome.jsp").forward(request, response); }else { request.setAttribute("message", "请输入正确的用户名和密码"); request.getRequestDispatcher("/index.jsp").forward(request, response); } }
if(null == name && name.trim().equals("") ) { request.setAttribute("message", "请输入用户名和密码"); request.getRequestDispatcher("/index.jsp").forward(request, response); } if(null == password && password.equals("")){ }
------解决方案--------------------
转发了方法其实并没有结束,如果想结束方法还得在后面加return关键字。