Aliy
Aliy

Reputation: 217

Return string object as XML object using Spring 4 in Java

Good morning

I'm using Spring 4 with only annotations(NO XML configuration). I know using Spring 3, we can use

@RequestMapping(value="/cui", 
        method=RequestMethod.GET,
        produces={"application/xml")

Now my method signature is

@GetMapping("/cui") 
public String cui() {
  String responseXML = // This is my final result object which is XML.

}

How and where should I mention that I will return a XML object, but not String object in the controller?

Any ideas would be greatly appreciated.

Upvotes: 1

Views: 206

Answers (1)

Barath
Barath

Reputation: 5283

@GetMapping(value="/cui",produces = MediaType.APPLICATION_XML_VALUE) 
public String cui() {
  String responseXML = // This is my final result object which is XML.
   return responseXML;
}

Upvotes: 1

Related Questions