当我创建一个 Spring 项目时,我总是遇到 XLMNS 的问题。 XMLNS 到底是什么? 这些到底是什么?
<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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
我在哪里可以获得这些引用资料? (xmlns:xsi 和 xsi:schemeLocation 的资源。)这些有没有在线手册?我好像找不到他们。
注意 当我说引用时,我的意思是他们的正确网址
更新
在哪里可以看到 Spring bean、Spring Transactions、Spring MVC 等的 XML 命名空间?及其架构位置?
最佳答案
这里有一个很好的解释: what is the use of xsi:schemaLocation?
这是关于 xsd 配置的 springs 文档: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/xsd-config.html
注意:spring 现在建议不要在 xsd 中包含版本号,除非特别需要,所以你应该有:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
并且不是:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
"xmlns"定义当前元素的命名空间。
"xmlns:aop"定义当前元素中元素的命名空间,前缀为 "aop:"
关于java - Spring bean DTD 和 XMLNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17822466/