Thursday, October 20, 2011

Spring MVC @ResponseBody and manage headers

To use @ResponseBody and manipulate the response header us the following:

@RequestMapping(value = "/url", method = RequestMethod.GET, headers = { "Accept=application/json" })
public @ResponseBody
List handle(HttpServletResponse response,
@RequestHeader("headerID") String headerString) {
response.setHeader("responseHeaderProperty", String);
return service.doSomething();
}

No comments:

Post a Comment