p命名空间注入
- 需要有set方法
- 需要添加约束
xmlns:p="http://www.springframework.org/schema/p"
- 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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="people" class="cn.lee.bean.People" p:name="鲁迅" p:age="65">
</bean>
</beans>
c命名空间注入
- 需要有构造方法
- 需要添加约束
xmlns:c="http://www.springframework.org/schema/c"
- 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:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="people" class="cn.lee.bean.People" c:name="鲁迅" c:age="65"></bean>
</beans>