xsi:schemaLocation的用途是什么?我看到我們有多個url作為該屬性的值,例如在spring中:<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.0.xsd">為什么需要它,它的用途是什么?Spr
4 回答

一只萌萌小番薯
TA貢獻1795條經驗 獲得超7個贊
春天使用的Java XML解析器將讀取schemaLocation
值并嘗試從Internet加載它們,以驗證XML文件。反過來,Spring會攔截這些加載請求,并從其自己的JAR文件中提供版本。
如果省略schemaLocation
,則XML解析器將不知道從何處獲取模式以驗證配置。

叮當貓咪
TA貢獻1776條經驗 獲得超12個贊
An xmlns是文檔中的唯一標識符-不必是架構的URI:
XML名稱空間通過將它們與URI引用標識的名稱空間相關聯,提供了一種簡單的方法來限定可擴展標記語言文檔中使用的元素和屬性名稱。
xsi:schemaLocation 應該提供有關實際架構位置的提示:
可以在文檔中使用,以提供有關可用于評估的架構文檔的物理位置的提示。
添加回答
舉報
0/150
提交
取消