AJAX发送PUT请求引发的血案
2024-10-12 02:06:06
如果直接发送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>
最新文章
- 反编译.NET工程
- 廖雪峰js教程笔记14 file文件操作
- pycharm的安装
- Java多线程编程——进阶篇二
- Two classes have the same XML type name 排错【转】
- WPF 控件截图位置不正确的问题
- 搭建你的持续集成server - CruiseControl step by step(1)
- Uva 409-Excuses, Excuses!(串)
- Could not resolve view with name &#39;***&#39; in servlet with name &#39;dispatcher&#39;
- Java多线程(一) 什么是线程
- BZOJ4997 [Usaco2017 Feb]Why Did the Cow Cross the Road III
- 封装JedisClient.提供API实现对redis的操作
- SSM 后台封装的有值, 到前台打印的时候没有值
- js dom添加回车事件
- Linux内核中断处理体系分析
- C#中的抽象类与重写
- Python中的strip()的理解
- UNIX和linux系统性能监控工具oswatcher
- PTA L2-001 紧急救援-最短路(Dijkstra)多条最短路找最优解并输出路径 团体程序设计天梯赛-练习集
- springmvc中拦截器与springmvc全局异常处理器的问题
热门文章
- WebGL three.js学习笔记 使用粒子系统模拟时空隧道(虫洞)
- PHP全栈学习笔记12
- Vue 进阶之路(七)
- angular2-7中的变化监测
- Linux创建普通用户
- VSCode Python开发环境配置
- 兼容IE8浏览器移除class样式的方法
- Mac OS X中开启或关闭显示隐藏文件命令
- The specified type member &#39;Date&#39; is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
- Kafka系列2-producer和consumer报错