For example if we have -
@RequestMapping(value = "/someurl", method = {
RequestMethod.POST, RequestMethod.GET}, produces = {
MediaType.TEXT_HTML_VALUE, MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
Edit What will be the response content-type?
For two different accept
headers -
Thanks
It depends on configured content negotiation and type selected by request. For example if request has header Accept: application/json or client requested resource with suffix ".json" he will receive json response. http://spring.io/blog/2013/05/11/content-negotiation-using-spring-mvc
Your understanding of the parameter is wrong. It does filter the incoming request by types the client accepts. As an example: If you are just producing "text/html" but the client only accepts "application/json" your mapped function in the controller denies the request.
Side note: Which type to produce can be configured with content negotiation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.