Using @ResponseBody my controller returns a JSON representation of my pojo by default, but is possible to change the view to JSP by default, and return a JSON response only when your content type is application/json
?
@RequestMapping(value="/myRequest")
public @ResponseBody myPojo myRequest() throws Exception {
return service.getMyPojo();
}
PS: I've tried ContentNegotiatingViewResolver
, but I'm not sure is the best one for achieving this.