I have the requirement to return the result from the database either as a string in xml-structure or as json-structure. I\'ve got a solution, but I don\'t know, if this one
You can use ContentNegotiatingViewResolver as below:
In your controller:
@RequestMapping(value = "/get/response.json", method = RequestMethod.GET)
public JSONResponse getJsonResponse(){
return responseService.getJsonResponse();
}
@RequestMapping(value = "/get/response.xml", method = RequestMethod.GET)
public XMLResponse getXmlResponse(){
return responseService.getXmlResponse();
}