Just see the code snippet of SpringMVC-3.2.x
controller action method. Its quite easy to generate JSON
but unable to add addtional custom header only f
You can also use HttpServletResponse
for adding your status and headers in a more easy way:
@RequestMapping(value="ajaxSuccess", method = RequestMethod.GET)
@ResponseBody
public String ajaxSuccess(HttpServletResponse response) {
response.addHeader("header-name", "value");
response.setStatus(200);
return "Body";
}
Therefore you need to add following maven dependency as provided:
org.apache.tomcat
tomcat-servlet-api
7.0.53
provided