Spring @ModelAttribute Model field mapping

前端 未结 2 1425
感动是毒
感动是毒 2021-01-20 22:24

I am rewriting an old REST service written in an in-house framework to use Spring. I have a Controller with a POST method which takes a parameter either as a POST or as

相关标签:
2条回答
  • 2021-01-20 22:59

    The @JsonProperty annotation can only work with the JSON format, but you're using x-www-form-urlencoded.

    If you can't change your POST type, you have to write your own Jackson ObjectMapper:

    @JsonProperty not working for Content-Type : application/x-www-form-urlencoded

    0 讨论(0)
  • 2021-01-20 23:21

    I also met a similar case you, Please replace @ModelAttribute("some_property") with @RequestBody.

    Hope to help you!

    0 讨论(0)
提交回复
热议问题