1.通过注解适配请求String
@RequestBody String requestBody
//收到微信服务器的http:xml请求
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
//返回微信服务器的http:xml响应
WxMpXmlOutMessage outMessage = this.route(inMessage);
XStream在toXML的时候对于Null值不进行标签输出
2.将请求由String-->Xml:使用 XStream
2.1 java转换xml
public void testXml(){
City city = new City();
city.setName("北京");
city.setDescription("中国首都");
XStream xstream = new XStream();
xstream.alias("city", City.class);//若不写这句,根标签是City的全路径名
String xml = xstream.toXML(city);
System.out.println(xml);
}
<city>
<name>北京</name>
<description>中国首都</description>
</city>
2.2 List集合转化为XML
@Test
public void