response.sendRedirect("index.jsp"); 第二次请求又进入了filter

解决方案 »

  1.   

    String name=(String)session.getAttribute("name"); 
    if(null==name) 

    response.sendRedirect("index.jsp"); 
    }else 

    chain.doFilter(req, res); 
    } 修改成为下面的代码:
    Object obj= session.getAttribute("name"); 
    if(null==obj) 

    response.sendRedirect("index.jsp"); 
    return;
    }chain.doFilter(req, res); 
      

  2.   

    支持,楼主可以把index.jsp排除
      

  3.   

    if((null==name) && !("index.jsp".equals(req.getContextPath()+req.getServletPath()))) 

    response.sendRedirect("index.jsp"); 
    }else 

    chain.doFilter(req, res); 

      

  4.   

    if((null==name) && !("/index.jsp".equals(req.getContextPath()+req.getServletPath()))) 

    response.sendRedirect("index.jsp"); 
    }else 

    chain.doFilter(req, res); 
      

  5.   

    我怀疑是你 index.jsp 
    里面是不是
    <script>
      window.loaction.href ='';   
    </script>

    <%
       request.setRedirect('');
       或
        request.forward(''); 
       等等啊
    %>
    什么的啊
      

  6.   

    response.sendRedirect("index.jsp"); 
    改成...
    RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp"); 
    dispatcher.forward(request, response); 
    或者调用一个action返回到index.jsp
    RequestDispatcher dispatcher = request.getRequestDispatcher("index.do"); 
    dispatcher.forward(request, response); 
      

  7.   


    我怀疑是你 index.jsp 
    里面是不是 
    <script> 
      window.loaction.href ='';  
    </script> 
    或 
    <% 
      request.setRedirect(''); 
      或 
        request.forward(''); 
      等等啊 
    %> 
    什么的啊 .
    我从2005年用到现在还没出现过,你这样的问题
      

  8.   

    如果你的连接不是登陆表单的地址且session取到的内容为空,那么转向表单地址
    否则,如果地址是用来登陆的,那么就doFilter