清空Request,用HttpServletRequestWrapper

1.request.getParameterMao().clear();

2.class MyHttpServletRequestWrapper extends HttpServletRequestWrapper {
       private Map params;
       public MyHttpServletRequestWrapper(HttpServletRequest originalRequest) {
          super(originalRequest);
          params = originalRequest.getParameterMap();
          Enumeration en = originalRequest.getParameterNames();
          while(en.hasMoreElements()){
              params.remove(en.nextElement());
          }
       }
      
       public Map getParameterMap() {
          return params;
       }
      
       public String getParameter(String name) {
           return (String)params.get(name);
        }
       public Enumeration getParameterNames() {
        return Collections.enumeration(params.keySet());
        }
       public String[] getParameterValues(String name) {
        return (String[])params.get(name);
        }
}

你可能感兴趣的:(SpringMVC)