Spring beans DTD 和 XMLNS
Spring beans DTD 和 XMLNS
当我创建一个Spring项目时,我总是遇到XMLNS的问题。XMLNS到底是什么?这些是什么东西?
我在哪里可以找到这些的参考文献?(xmlns:xsi和xsi:schemeLocation的资源)。这些有在线手册吗?我似乎找不到它们。
注意:当我说参考文献时,我是指它们的正确网址。
更新:
我应该在哪里查看Spring Bean,Spring Transaction,Spring MVC等的XML命名空间?它们的模式位置在哪里?
这些行为您的XML文档设置命名空间。根据您在XML文件中使用的标记,您需要在顶部(并引用正确的模式)使用命名空间,以使XML有效。
例如,如果您在bean定义中使用
标记,则需要在文件顶部引用aop架构:xmlns:aop="http://www.springframework.org/schema/aop"
如果您不使用该标记,则不需要在那里。
对于您导入的任何命名空间,请确保将引用添加到“xsi:schemaLocation”标记中,如下所示:xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
我建议查看Spring应用程序示例,因为它应该具有您需要运行的最低要求。
这里有一个很好的解释:
以下是 Spring 在 xsd 配置方面的文档:
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:" 的元素定义命名空间。