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
- <Bean id="code" class="cn.easypm.www">
- <property name="Maxspeed">
- <value>200</value>
- </Property>
- <property name="brand">
- <value><![ cdata[easypm&ca72]]></value>
- </Property>
- </Bean>
Special character processing for XML