Spring @RequestBody支持GET方法吗? [英] Does Spring @RequestBody support the GET method?

查看:1217
本文介绍了Spring @RequestBody支持GET方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在HTTP GET请求消息中携带JSON数据,但是我的Spring MVC服务器似乎无法从GET请求体中检索JSON数据。

解决方案HTTP的 GET 方法不包含请求主体作为规范的一部分。 Spring MVC尊重HTTP规范。具体来说,服务器可以放弃身体。请求URI应包含制定响应所需的一切。



如果您需要请求主体,请将请求类型更改为包含请求主体的POST。 p>

I am trying to carry JSON data in an HTTP GET request message, but my Spring MVC server can't seem to retrieve the JSON data from the GET request body.

解决方案

HTTP's GET method does not include a request body as part of the spec. Spring MVC respects the HTTP specs. Specifically, servers are allowed to discard the body. The request URI should contain everything needed to formulate the response.

If you need a request body, change the request type to POST, which does include the request body.

这篇关于Spring @RequestBody支持GET方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆