Spring 3.1 or Later @RequestMapping Consumes/Produces

后端 未结 3 1772
一生所求
一生所求 2020-12-24 02:40

I have a question in regards to the consumes and produces part of the @RequestMapping. I have an endpoint that I want to accept both JSON and XML and return JS

3条回答
  •  遥遥无期
    2020-12-24 02:49

    Well,

    consumes/produces takes String[] as a parameter (see RequestMapping from Spring's documentation) so I believe it will work. You can also try headers = "content-type=application/json,application/xml".

提交回复
热议问题