I get this error when I run a certain Spring Web 3 project in NetBeans:
org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 30; The prefix "mvc" for element "mvc:annotation-driven" is not bound.
Here's dispatcher-servlet.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="net.myproject.controllers"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
</beans>
I think I did the appropriate namespace declarations, but obviously I'm still overlooking something. Why am I getting this error?
8条答案
按热度按时间ef1yzkbh1#
这是一个IDE错误,可以通过执行以下操作解决
xmlns:mvc=”http://www.springframework.org/schema/mvc“(中文)
p4rjhz4m2#
试试这个对我很有效:
evrscar23#
它应该是这样工作的,而且它对我很有效。问题可能出在IDE / xml编辑器中。请尝试忽略xml错误并运行应用程序。
3htmauhk4#
这是一个IDE错误,可以通过将以下内容添加到Spring Dispatcher Servlet中来解决
xmlns:mvc=”http://www.springframework.org/schema/mvc“(中文)
如果xml文件中不包含以下代码段,请添加它。
您http://www.springframework.org/schema/mvc。
zbdgwd5y5#
Changing below code worked for me
to below code (imp : check xmlns:context and xmlns:xsi position)
ig9co6j16#
您可能遗漏了命名空间宣告的某个重要部分,如下所述:http://forum.springsource.org/showthread.php?100397-The-prefix-mvc-for-element-mvc-annotation-driven-is-notbound
它不会影响运行时,但是开发环境会遇到与您所描述的类似的问题。
我猜应该是这样的:http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
irlmq6kh7#
添加:xmlns:p=”http://www.springframework.org/schema/p“
否则xml将无法理解p注解。
w6lpcovy8#
我也遇到了同样的问题,于是我补充道:http://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd到xsi:schemaLocation下面是我的bean标记: