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/>是否合格。

相关文章:

  • 2021-09-05
  • 2021-11-02
  • 2021-12-22
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-29
  • 2021-11-04
  • 2021-09-29
  • 2022-02-26
  • 2021-09-05
  • 2021-07-17
  • 2021-11-14
相关资源
相似解决方案