2016-09-17 105 views
0

我在我的java EE代码中遇到问题。我想从我的servlet的doPost()方法重定向到一个.jsp。但是在doPost()执行结束时没有任何反应。我在执行doPost方法之前在同一页上。有人可以帮我吗?从servlet重定向到.jsp

doPost()方法:

public static final String VUE_SUCCES = "/ajoutAbonne.jsp"; 
    .......... 

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    // TODO Auto-generated method stub 

    HttpSession session = request.getSession(); 
    String email = request.getParameter("email"); 
    session.setAttribute("login", email); 

    System.out.println("connexion réussie..."); 
    System.out.println(session.getAttribute("login")); 

    this.getServletContext().getRequestDispatcher(VUE_SUCCES).forward(request, response); 
} 
+0

ajoutAbonne.jsp是在你的web应用程序的根级别?你在AS的控制台中看到“connexionréussie...”吗? –

+0

是的,我看到“connexionréussie”,但我留在同一页。是的ajoutAbonne.jsp是我的webApp的根。 –

+0

您是否检查过AS的日志文件以查看是否有异常? –

回答

0

,你可以尝试像波纹管

response.sendRedirect是( “MyFolder中/的welcome.jsp”);

response.sendRedirect(VUE_SUCCES);