spring的p-namepace(简写标记)



spring的p-namepace(简写标记)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"s

       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="springDemo2.Person"
                 p:id="111"
                 p:name="45"
                 p:age="14"

/>

//给PersonDao对象的Person对象属性赋值

       <bean id="personDao" class="springDemo2.PersonDao"
                 p:dao="888"
                 p:person-ref="person"

/>