java - Spring bean DTD 和 XMLNS

标签 java spring javabeans

当我创建一个 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/

相关文章:

java - 从接口(interface)访问单例的引用,可以吗?

java - 没有时间的日期比较

java 小程序不使用 1.6 update 24 和 IE/Chrome 进行缓存

java - 为什么 Hibernate 会查询两次?

java - 消耗仇恨 : Non-matching JSON-request generated

java - 动态使用 Java bean 和 Servlet 值

Java Lambda 函数在连接到 Informix DB 时超时

java - 从 hibernate session 中删除对象?

java - 在 Eclipse 上学习 Java(专注于企业)的好书

java - 我应该如何从托管 bean 内的数据库读取数据?