Controller method with two @RequestBody
See original GitHub issueI extend spring-mvc’s HandlerMethodArgumentResolver to support multi @ReqestBody param on controller’s method. The @ReqestBody annotation was rewrite to support value param:
@RequestMapping(method=RequestMethod.POST, value="person-cars-post")
@ApiOperation(value = "create person and car", httpMethod="POST")
public ModelAndView<Person> createPersonAndCar1(@RequestBody("person") Person person, @RequestBody("car") Car car) {
return ModelAndViewUtils.successWithView(person, "persons/list");
}
The program works fine, but springfox parses the two params to two body. On site of the swagger ui shows:
Parameters
person:
{ "addresses": [ { "id": "string", "name": "string" } ], "id": "string", "name": "string", "sex": "string" }
car :
{ "color": "string", "id": "string", "level": "string" }
When I clicked “Try it out!”, it only sended the person’s input.
Shoud i modify the swagger ui or config springfox?
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Passing multiple variables in @RequestBody to a Spring MVC ...
You can do it like this way: @RequestMapping(value = "/Test", method = RequestMethod. POST) @ResponseBody public boolean getTest(@RequestBody ObjectNode ...
Read more >Spring-mvc – Multiple @RequestBody values in one controller ...
I'm receiving error 400 when I send PATCH request to my endpoint that looks like this @RequestMapping(value = "...", method = RequestMethod.
Read more >Passing multiple variables in @RequestBody to a Spring MVC ...
Coding example for the question Passing multiple variables in @RequestBody to a Spring MVC controller using Ajax-Spring MVC.
Read more >Support multiple @RequestBody [SPR-9434] #14070 - GitHub
There is a very good chance you will need this functionality in more than one controller method.
Read more >Spring @RequestBody - binding method ... - ZetCode
@RequestBody annotation binds request body to method parameters. The process of serialization/deserialization is performed by ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
if you will use like these you will get desired output. Here ( @RequestPart String data ) is a model class you can not pass model class directly as parameter, so you need to give datatype & after that you should convert it. @RequestMapping(value = “/mail”, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, method = RequestMethod.POST) public ResponseEntity<String> uploadFile(@RequestPart String data, @RequestPart MultipartFile file)
Thanks! I will try to modify the swagger ui.