# p 名称空间给对象的属性注入值(spring3.0以上版本才支持)
需要引入:
xmlns:p="http://www.springframework.org/schema/p"
举例 applicationContext.xml
<?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"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><!-- ###############对象属性赋值############### --><!-- 给对象属性注入值:# p 名称空间给对象的属性注入值(spring3.0以上版本才支持)--><bean id="userDao" class="c_property.UserDao"></bean><bean id="userService" class="c_property.UserService" p:userDao-ref="userDao"></bean><bean id="userAction" class="c_property.UserAction" p:userService-ref="userService"></bean><!-- 传统的注入: <bean id="user" class="c_property.User" ><property name="name" value="xxx"></property></bean>--><!-- p名称空间优化后 --><bean id="user" class="c_property.User" p:name="Jack0001"></bean></beans>