Discuz! Board

标题: 关于spring的xml文件中使用的命名空间 [打印本页]

作者: zangcf    时间: 2016-2-28 09:45
标题: 关于spring的xml文件中使用的命名空间
关于xml的详细教程,我现在有韩顺平的和张龙的,这两个教程在我的360云盘和百度云盘中都有。

作者: zangcf    时间: 2016-2-28 09:45
本帖最后由 zangcf 于 2016-2-28 09:47 编辑

Spring 的配置文件中,有一个配置文件头:
<beans xmlns=”http://www.springframework.org/schema/beans
xsi:schemaLocation=”http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”>
这表明,在当前配置文件中,使用的是beans命名空间,可以直接使用<bean id=”">。
如果要在这个配置文件中使用mvc命名空间下的annotation-driven元素,要写为<mvc:annotation-driven/>,当然,还需要告诉xml解析器,mvc这个命名空间是在哪里定义的,以便解析器能够验证当前文件中mvc:开头的元素是否符合mvc命名空间的:
<beans xmlns=”http://www.springframework.org/schema/beans
xmlns:mvc=”http://www.springframework.org/schema/mvc
xsi:schemaLocation=”http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd”>
这样解析器在解释mvc:命名空间的时候,会参考spring-mvc-3.0.xsd这个文件来检验<mvc:annotation-driven/>是否合格。





欢迎光临 Discuz! Board (http://47.89.242.157:9000/bbs/discuz/) Powered by Discuz! X3.2