P命名空间
官网:
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
https://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
使用:
<!-- p命名空间注入,可以直接注入属性的值:property-->
<bean id="user" class="cn.aguoke.pojo.User" p:name="张三" p:age="18"/>
C命名空间
官网:
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
https://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
使用:
<!-- c命名空间注入,通过构造器注入:construct-args-->
<bean id="user" class="cn.aguoke.pojo.User" c:name="张三" c:age="18"/>
c命名和p命名需要导入xml约束