@RequestMapping(value = "/path", produces = "application/xml;charset=UTF-8")
@ResponseBody
public String getFlowCacheWithXml(String svcCode) {
Bean obj=...
String xml = "";
try {
XStream xStream = new XStream();
xStream.alias("BeanType", BeanType.class);
xml = xStream.toXML(obj);
} catch (Exception e) {
e.printStackTrace();
}
return xml;
}
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>${xstream.version}</version>
</dependency>