P名称空间
名称空间
xml中名称空间是防止标签重复的,如下所示:
<book>
<name>西游记</name>
<price>19.99</price>
<author>
<name>吴承恩</name>
<gender>男</gender>
</author>
</book>
此时发现xml中有两个name标签,于是我们加一个简单的区分,带一个前缀:
<book>
<a:name>西游记</a:name>
<price>19.99</price>
<author>
<b:name>吴承恩</b:name>
<gender>男</gender>
</author>
</book>
p名称空间
此时不需要再写标签来注入属性,不会产生重复的标签名
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
//导入p名称空间
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!--使用名称空间-->
<bean id="person" class="com.atguigu.bean.Person" p:age="18"
p:email="xiaoming@168.com" p:lastName="小明" p:gender="男">
</bean>
</beans>