request.getRequestDispatcher("").forward(request, response);跳转不了、这是为毛、为毛啊??!!!
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletE...
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String userName = request.getParameter("account");
String pwd = request.getParameter("password");
Admin admin;
User_LoginDao ad=new User_LoginDao();
admin=ad.getAdmin(userName,pwd);
System.out.println("rrrrrrrrrrrr"+userName+pwd);
if(admin!=null){
System.out.println("4444444444");
request.getSession().setAttribute("session_userName", userName);
request.getSession().setAttribute("session_pwd", pwd);
response.sendRedirect("index.jsp");
}
else{
System.out.println("333333");
request.setAttribute("error","账号或密码错误,请重新核实!");
request.getRequestDispatcher("web/user_login.jsp").forward(request, response);
}
}
web就是webroot下的文件夹、index.jsp是默认的……求大神 展开
throws ServletException, IOException {
String userName = request.getParameter("account");
String pwd = request.getParameter("password");
Admin admin;
User_LoginDao ad=new User_LoginDao();
admin=ad.getAdmin(userName,pwd);
System.out.println("rrrrrrrrrrrr"+userName+pwd);
if(admin!=null){
System.out.println("4444444444");
request.getSession().setAttribute("session_userName", userName);
request.getSession().setAttribute("session_pwd", pwd);
response.sendRedirect("index.jsp");
}
else{
System.out.println("333333");
request.setAttribute("error","账号或密码错误,请重新核实!");
request.getRequestDispatcher("web/user_login.jsp").forward(request, response);
}
}
web就是webroot下的文件夹、index.jsp是默认的……求大神 展开
2个回答
展开全部
看你的程序估计是admin!=null所以执行不到else里的 request.getRequestDispatcher
当然
request.getRequestDispatcher("web/user_login.jsp").forward(request, response);里web前要加/
当然
request.getRequestDispatcher("web/user_login.jsp").forward(request, response);里web前要加/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
报什么错误,截个图来看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询