码迷,mamicode.com
首页 > 其他好文 > 详细

为什么这个地方用重定向会报错.只能用 服务器跳转?? 为什么我加了过滤器,还是能直接登陆 servlet

时间:2016-07-15 00:38:22      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
         request.setCharacterEncoding("utf-8");
        String username= request.getParameter("username");
        HttpSession session = request.getSession();
        session.setAttribute("username", username);
        //request.setAttribute("username", username);//一定要保存,OGNL才能获取${username}
        //或者直接在jsp页面中用<%=request.getParameter("username")获取,两种结果一样,但是后者有null
    request.getRequestDispatcher("/success.jsp").forward(request, response);
        
        //response.sendRedirect("/success.jsp");//会报错.原因不懂
    }

 

为什么这个地方用重定向会报错.只能用 服务器跳转?? 为什么我加了过滤器,还是能直接登陆 servlet

标签:

原文地址:http://www.cnblogs.com/xuedexin/p/5672023.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!