mvc:注释驱动未绑定 [英] mvc:annotation-driven is not bound

查看:75
本文介绍了mvc:注释驱动未绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在NetBeans中运行某个Spring Web 3项目时出现此错误:

I get this error when I run a certain Spring Web 3 project in NetBeans:

org.xml.sax.SAXParseException; lineNumber:11; columnNumber:30;这 元素的前缀"mvc" 未绑定"mvc:annotation-driven".

org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 30; The prefix "mvc" for element "mvc:annotation-driven" is not bound.

这里是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?

推荐答案

它应该像这样工作,并且对我有用.问题可能出在您的IDE/xml编辑器中.尝试忽略xml错误并运行应用程序.

It should work like that, and it works for me. The problem might be in your IDE / xml editor. Try ignoring the xml error and run the application.

这篇关于mvc:注释驱动未绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆