Why do field names suddenly have double underscores in the generated XML?
XStream maps Java class names and field names to XML tags or attributes. Unfortunately this mapping cannot be 1:1, since some characters used for identifiers in Java are invalid in XML names. Therefore XStream uses an XmlFriendlyNameCoder to replace these characters with a replacement. By default this NameCoder uses an underscore as escape character and has therefore to escape the underscore itself also. You may provide a different configured instance of the XmlFriendlyNameCoder or a complete different implementation like the NoNameCoder to prevent name coding at all. However it is your responsibility then to ensure, that the resulting names are valid for XML.
[url]http://xstream.codehaus.org/faq.html[/url]
1、1.4及以后
2、1.4之前
<bean id="marshaller" class="org.springframework.oxm.xstream.AnnotationXStreamMarshaller">
<property name="streamDriver">
<bean class="com.thoughtworks.xstream.io.xml.XppDriver">
<constructor-arg>
<bean class="com.thoughtworks.xstream.io.xml.XmlFriendlyReplacer">
<constructor-arg index="0" value="_-"/>
<constructor-arg index="1" value="_"/>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
3、注册到spring mvc
mvc:annotation-driven
mvc:message-converters
/mvc:message-converters
/mvc:annotation-driven