给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文件中&改为&amp;

&是显示结果

&amp;是转义字符

也就是改为:

<prop key="url">jdbc:mysql://192.168.168.168:3360/gifts?useUnicode=true&characterEncoding=utf-8&amp;useSSL=true</prop>

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐