What you are asking for is fundamentally wrong. POST requests sends data in a body payload, which is mapped via @RequestBody
. @RequestParam
is used to map data through the URL parameters such as /url?start=foo
. What you are trying to do is use @RequestParam
to do the job of @RequestBody
.
@RequestBody Map<String, String> payload
. Be sure to include ‘Content-Type‘: ‘application/json‘
in your request header.@RequestParam
, use a GET request instead and send your data via URL parameters.@ModelAttribute
.@RequestBody Map<String, String> payload
. To do this, please see this answer.It is not possible to map form data encoded data directly to a Map<String, String>
.
原文:https://www.cnblogs.com/sidesky/p/15185929.html