The prefix "mvc" for element "mvc:annotation-driven" is not bound 异常

使用STS或者eclipse 开发SpringMVC应用 时,我靠。。有个小小的东西没注意搞了半天,

STS在创建SpringMVC工程时,自动生成了Dispatcher的配置文件,然后看教程时,使用了<mvc:annotation-driven> 注解配置

但是自动生成的xml里呢有一个<annotation-driven>, 挺疑惑的,以为mvc约束文件版本不对,所以配置了很久的本地约束,仍然没有用

后来决定仔细看看什么问题,通过代码排版对齐,发现了。。。。。靠,前缀也是需要配置的!!改成下面所示代码。OK了

 

注意蓝色的是以前的,改成红色的,就多了个  :mvc

 

The prefix "mvc" for element "mvc:annotation-driven" is not bound异常

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans

    xmlns= "http://www.springframework.org/schema/mvc"

    xmlns:mvc="http://www.springframework.org/schema/mvc"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:beans="http://www.springframework.org/schema/beans"

    xmlns:context="http://www.springframework.org/schema/context"

    xsi:schemaLocation="

        http://www.springframework.org/schema/mvc

        http://www.springframework.org/schema/mvc/spring-mvc.xsd

        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">

   

    <mvc:annotation-driven />

    <mvc:resources location="/resources/" mapping="/resources/**"/>

       

</beans:beans>

 

posted @ 2017-09-16 13:10  毛豆特  阅读(14825)  评论(0编辑  收藏  举报