MVC Spring: Can we get an XML response if I passed the json parameters in the body for the request by mail?

I did google around it, but I got a couple of links that are described, we cannot get an XML response if parameters are passed as body to request by mail. Please confirm if this is possible in spring? If so, please share the annotation or any related advice, I can look forward to it. Any help would be appreciated.

+3


source to share


1 answer


You can use RequestMapping annotation. It has an element that specifies the type of response returned. If you want to force XML as return type you can use something like this

@RequestMapping(value="/someresource", 
                method=RequestMethod.POST, 
                produces=MediaType.APPLICATION_XML)

      



Another example - if you only want to use JSON and XML, but you like returning XML:

@RequestMapping(value="/someresource", 
                method=RequestMethod.POST,
                consumes={MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON},
                produces=MediaType.APPLICATION_XML)

      

+2


source