我通常看到spring模塊是基於命名空間加載的,儘管我對此有些模糊的理解,但對我來說這並不明確。春天是如何基於命名空間的作品?
<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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
>
春季如何在內部使用上述類似情況下,對等申報命名空間?
這是我的理解: -
春季內部解析XML。
在解析,它會嘗試找出所有 的XSD預期罐子(它在內部知道反對的schemaLocation值罐子名)
春處理器驗證和處理基於 命名空間的元素(如背景下, p),其中背景下,對等的默認 命名空間中的XSD的下一個步驟中發現2
它是正確的嗎?
請記住,標籤中使用的實際名稱空間名稱是不相關的。它們只是與它們關聯的XSD定義的簡寫鍵。 – chrylis
@chrylis能否詳細說明「請記住,標籤中使用的實際名稱空間名稱是不相關的」? – emilly
不管你使用'context'還是'c'還是'foobar'都不重要。唯一重要的是名稱空間名稱(例如「context」)與名稱空間URI列表中的鍵匹配。 – chrylis