所 有 使 用 XML 文 件 进 行 配 置 信 息 加 载 的 Spring IoC 容 器 , 包 括 BeanFactory 和
ApplicationContext的全部XML相应实现,都使用统一的XML格式。在Spring 2.0版本以前,这种格
式由Spring提供的DTD规定,也就是说,全部的Spring容器加载的XML配置文件的头部,都须要如下
形式的DOCTYPE声明:spring
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" ➥ "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> ... </beans>
从Spring 2.0版本以后,Spring在继续保持向前兼容的前提下,既能够继续使用DTD方式的DOCTYPE
进行配置文件格式的限定,又引入了基于XML Schema的文档声明。因此,Spring 2.0以后,一样能够
使用代码清单4-11所展现的基于XSD的文档声明。spring-mvc
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 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
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd "> </beans>