Spring MVC - Why not able to use @RequestBody and @RequestParam together

后端 未结 4 1979
闹比i
闹比i 2020-11-28 03:06

Using HTTP dev client with Post request and Content-Type application/x-www-form-urlencoded

1) Only @RequestBody

URL: localhost:8080/SpringMVC/welcome
B

4条回答
  •  遥遥无期
    2020-11-28 03:37

    You could also just change the @RequestParam default required status to false so that HTTP response status code 400 is not generated. This will allow you to place the Annotations in any order you feel like.

    @RequestParam(required = false)String name
    

提交回复
热议问题