当前位置 : 主页 > 编程语言 > c++ >

过滤器的xml配置和使用

来源:互联网 收集:自由互联 发布时间:2021-07-03
用于过滤没用进行用户登入的访问 MyFilter MyFilter org.jxnd.Fliter.MyFilter MyFilter /* //里面的内容是用于写需要过滤的路径 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain
用于过滤没用进行用户登入的访问
 
    
  
   MyFilter
  
    
  
   MyFilter
  
    
  
   org.jxnd.Fliter.MyFilter
  
  
 
  
 
    
  
   MyFilter
  
    
  
   /*
  //里面的内容是用于写需要过滤的路径
  
 

  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		// TODO Auto-generated method stub
		// place your code here
		HttpSession session=((HttpServletRequest)request).getSession();
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		String name=request.getParameter("name");
		session.setAttribute("name", name);
		if(((HttpServletRequest)request).getServletPath().equals("/NewFile.jsp")){
			
			chain.doFilter(request, response);
			
		}else if(session.getAttribute("name")!=null&&session.getAttribute("name")!=""){
			chain.doFilter(request, response);
		}else{
			
		}
	}
网友评论