Announcement Announcement Module
Collapse
No announcement yet.
No way to annotate response body content-type (3.1.1)? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No way to annotate response body content-type (3.1.1)?

    I realize this question is asked a lot, based on my googling for an answer. But none of the solutions I found seem straightforward. They all revolve around injecting a message converter in the config XML file, and setting the response type parameter on that.

    But I want to set the response type per-method in my controller classes. I tried using RequestMapping(produces), but that seems to have no effect (this is on a method annotated with @ResponseBody).

    I can, of course, write my responses to the HttpServletResponse output stream (in fact, this is what I was doing until an hour ago when I discovered @ResponseBody), but I like the tidiness of @ResponseBody. I just wish I could do @ResponseBody(contentType="application/json;charset=UTF-8").

    Thanks!

  • #2
    Actually, on second thought, maybe ResponseEntity<String> is a better way to go, because I need to set the response code at run time.

    Comment

    Working...
    X