大LOVE辉
2016-08-10 16:09
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException
{
HttpServletRequest request = (HttpServletRequest) arg0;
HttpServletResponse response = (HttpServletResponse) arg1;
HttpSession session = request.getSession();
if(session.getAttribute("username")!=null)
{
arg2.doFilter(arg0, arg1);//允许放行!
}
else
{
response.sendRedirect(request.getContextPath()+"/login.jsp");
}
}
把request.getContextPath()+去掉应该就可以了
Java Web开发技术应用——过滤器
70492 学习 · 258 问题
相似问题
回答 1
回答 2