Find an error today and find that the XML cannot contain special characters: &, to summarize:
There are 5 special characters in the XML, namely,:&<> "'. If the injected value in the configuration file includes these special characters, special processing is required. There are two workarounds: first, the <! in this example [cdata[]]> Special tags, wrapping strings containing special characters, and second, using XML escape sequences to represent these special characters, the corresponding XML escape sequences for these 5 special characters are described in table 4-2:
When spring is in the XML configuration, if the property value contains a special symbol for the XML, we deliberately add a <! outside the property value. [cdata[]]> 's XML special handling tag, <! [cdata[]]> 's role is to have the XML parser treat the string in the tag as plain text to prevent some strings from damaging the XML format. Take a look at an example:
XML code:
Java code
<BeanID= "Car"class= "Com.baobaotao.attr.Car"> < Propertyname= "Maxspeed"> <value>200</value> </ Property> < Propertyname= "Brand"><value><! [Cdata[Red Flag &ca72]]></value> </ Property></Bean>
If you use an XML escape sequence, we can replace the configuration in Listing 4-10 with the following configuration:
XML code:
Java code
<name= "brand"><value> red flag & CA72</value></Property>
Reference: http://hechuanzhen.iteye.com/blog/1739062/
[Spring] Rules for special characters in spring configuration files