spring 中 @RequestBody的使用

一般正常情况下 jquey中ajax 请求的  contentType 的 类型为 application/x-www-form-urlencoded ,是把传过来的参数变成key value 形式,后台可以使用request.getParameter("name")来获取值。

如果请求头中contentType 变成appliaction/json或其他形式,

那么request.getParameter("name")是获取不到数据的,  这时要使用

@ ResqusetBody 来获取参数,注意参数类型是json格式,一般用于第三方调用后台接口较多。在项目中只要注意传的

contenttype 类型即可。

猜你喜欢

转载自blog.csdn.net/hyhanyu/article/details/80283241
今日推荐