Spring命名空间之c和p
1.c命名空间
如需使用c命名空间, 需在xml配置文件中给beans添加如下属性
xmlns:c="http://www.springframework.org/schema/c"
c命名空间其实就是调用有参构造方法
创建对象
<bean id="cat1" class="com.ml.pojo.Cat" c:name="小花猫2" c:gender="公" c:color="花色"/>
2.p命名空间
如需使用p命名空间, 需在xml配置文件中给beans添加如下属性
xmlns:p="http://www.springframework.org/schema/p"
p命名空间其实就是调用无参构造方法
创建对象, 使用set
方法注入属性值
<bean id="cat2" class="com.ml.pojo.Cat" p:name="小花猫" p:gender="公" p:color="花色"/>