AJAX发送PUT请求引发的血案
 如果直接发送ajax=put形式的请求
      是拿不到请求体中的数据的。
     
      Tomcat:
              1、将请求体中的数据,封装一个map
              2、request.getParameter("empName")就会从这个map中取值
              3、SpringMVC封装POJO对象的时候
                      会把POJO中每个属性的值,request.getParameter("email");
      AJAX发送PUT请求引发的血案:
              PUT请求:请求体中的数据,request.getParameter("empName")拿不到
              Tomcat一看是PUT请求不会封装请求体中的数据为map,只有POST形式的请求才封装请求体为map
     
      tomcat源码中
org.apache.catalina.connector.Request--parseParameters() (3000多行) protected String parseBodyMethods = "POST";
if ( !getConnector().isParseBodyMethod(getMethod())){ success = true; return; }
解决方法:
1.ajax请求发送post方法,请求路径中+上 &_Method = PUT 或者
2. 配置过滤器
<filter> <filter-name>HttpPutFormContentFilter</filter-name> <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> </filter> <filter-mapping> <filter-name>HttpPutFormContentFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
                    
                
                
            
        
浙公网安备 33010602011771号