使用STS或者eclipse 开发SpringMVC应用 时,我靠。。有个小小的东西没注意搞了半天,spring
STS在建立SpringMVC工程时,自动生成了Dispatcher的配置文件,而后看教程时,使用了<mvc:annotation-driven> 注解配置spring-mvc
可是自动生成的xml里呢有一个<annotation-driven>, 挺疑惑的,觉得mvc约束文件版本不对,因此配置了好久的本地约束,仍然没有用mvc
后来决定仔细看看什么问题,经过代码排版对齐,发现了。。。。。靠,前缀也是须要配置的!!改为下面所示代码。OK了app
注意蓝色的是之前的,改为红色的,就多了个 :mvceclipse
The prefix "mvc" for element "mvc:annotation-driven" is not bound异常lua
<?xml version="1.0" encoding="UTF-8"?>spa
<beans:beansxml
xmlns= "http://www.springframework.org/schema/mvc"blog
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>