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靈活.
新聞熱點
疑難解答