struts2 控制台打印request 请求路径 filter 过滤器实现

@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
		ServletException
	{
		//
		request.setCharacterEncoding("UTF-8");
		
		HttpServletRequest req = getRequest();
        java.util.Enumeration<String> e2=req.getParameterNames();
        String param="";
        while(e2.hasMoreElements()){
                String key=e2.nextElement();
                param+=key+"="+(key==null?"":req.getParameter(key))+"&";
        }


       System.out.println("[url:]"+req.getRequestURI()+(param==null||"".equals(param)?"":"?"+param.substring(0, param.length()-1)));

		
		super.doFilter(request, response, chain);
	}

你可能感兴趣的:(struts)