What is represented in the spring bean configuration file p:
<bean id= "Daotemplate" abstract= "true" lazy-init= "true"
p:sessionfactory-ref= "Sessionfactory"/>
P indicates that the attributes inside the bean are injected in the form P: Property name = Injected Object
The same effect as using the <property> tag inside the bean
Spring2.0 also has a very useful parser, simplepropertynamespacehandle, if the configuration file references http://www.springframework.org/schema/p command space, You will use Simplepropertynamespacehandle to process the bean definition, and you can configure the Set value method injection in a simpler way in the bean in Spring2.0, as follows:
< XML version= "1.0" encoding= "UTF-8"?>
< beans xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
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= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "Close"
P:driverclassname= "Org.gjt.mm.mysql.Driver" p:url= "Jdbc:mysql://127.0.0.1:3306/easyjf-bbs" p:username= "root" P: password= "MySQL"/>
</beans>
In the above configuration, using P:url, you can inject Basicdatasource URL property values directly, and you can use the P:url-ref property to refer to another bean.
For example, Spring2.0 a previous DAO configuration:
< bean id= "Userdao" class= "Com.test.UserDao" >
< property name= "DataSource" >< ref bean= "DataSource"/></property>
</bean>
Using the short attribute method, change to the following:
< bean id= "Userdao" class= "Com.test.UserDao" p:datasource-ref= "DataSource"/>
Go P tags in Spring