给Properties注入值报错
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="stu" class="com.qzcsbj.bean.Student"> <property name="name" value="jack"/> <property name="p"> <props> <prop key="username">root</prop> <prop key="password">123456</prop> <prop key="url">jdbc:mysql://192.168.168.168:3360/gifts?useUnicode=true&characterEncoding=utf-8&useSSL=true</prop> <prop key="driver">com.mysql.jdbc.Driver</prop> </props> </property> </bean> </beans>
将xml文件中&改为&
&是显示结果
&是转义字符
也就是改为:
<prop key="url">jdbc:mysql://192.168.168.168:3360/gifts?useUnicode=true&characterEncoding=utf-8&useSSL=true</prop>