1.首先p名称空间是使用在xml schema配置当中的,所以请使用dtd约束的朋友将它转换一下,贴出以下xml schema配置
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
关键配置: xmlns:p="http://www.springframework.org/schema/p" 没有它p名称空间就没有p名称空间了(暂时的想法,如果有朋友知道有其他方式,那么请留言我)
2.p名称空间是在标签里面进行赋值的.贴出以下代码
<bean id="chinese" class="test.Chinese"
p:name="王宝强"
p:age="24"
p:axe-ref="axe"
/>
<bean id="axe" class="test.steelAxe"/>
其中name,age,axe都是Chinese实现类的属性,但是也没有像依赖检查(dependency-check)那样需要你全部输入.
3.关于其他的类,这里就不多说了.
4.但是有一点不自在的是,当你的bean实例的属性以-ref结尾(我猜没有那么巧)那么p名称空间就把-ref后面的值当做其中被调用实例来看待.
总结:所以p名称空间虽然很直观,简单,但是没有标准的xml灵活.