过滤器问题
我写的一个过滤器, 在登录后可以正常使用, 但退出后直接访问页面地址的话, 第一次不经过过滤器, 哪位能够帮忙解决, 在线等
public void doFilter(ServletRequest request, ServletResponse response,
				FilterChain chain) throws 
IOException, 
ServletException {
			// TODO Auto-generated method stub
			HttpServletResponse servletResponse = (HttpServletResponse)response;
			HttpServletRequest httpServletRequest = (HttpServletRequest)request;
	        Object userSession = null ;  
	         try{
	          	userSession = httpServletRequest.getSession(true).getAttribute("user");
	          	System.out.println("session=="+userSession) ;
	 	        if (userSession == null) {
	 	          	String path = httpServletRequest.getContextPath();
	 	           	servletResponse.sendRedirect(path+"/checkout.html");
	 	         }else
	 	        	chain.doFilter(request, response);
	            }catch(Exception e){
	            	e.printStackTrace() ;
	            }
	     }
这个是我的过滤器的部分代码
各位帮我看看有没有问题
------解决方案--------------------我觉得可能是web.xml里filter配置的问题
比如说应该是*.*,而你却只写了*.jsp之类
------解决方案--------------------你要判断一下是不是首页或是登录的action,如果是则允许通过就可以了。(总之不想验证的页面都要做个判断)
http://blog.csdn.net/wpabbs/archive/2008/08/21/2806677.aspx
部分代码:
 // 判断用户是否登录,如果没有,
 if (user == null || user.equals("")) {
  // 获锝当前的URL
  String strURL = sr.getRequestURL().toString();
  // 判断是否为index.jsp或userLogin.do
  if (strURL.indexOf("/index.jsp") == -1) {
         if (strURL.indexOf("/userLogin.do") == -1) {
......
------解决方案--------------------在web.xml中,filter的mapping中对/*进行过滤
------解决方案--------------------up!