Spring MVC返回XML

@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;
	}

			com.thoughtworks.xstream
			xstream
			${xstream.version}
		

 

你可能感兴趣的:(spring,mvc,java)