mvc:annotation-driven is not bound

后端 未结 7 1054
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-02 11:23

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

相关标签:
7条回答
  • 2021-02-02 11:48

    This is an IDE Error, Which can be resolved by adding the following to your Spring Dispatcher Servlet

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

    And also add the following snippet if it is not included in your xml file

    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"

    0 讨论(0)
  • 2021-02-02 11:50

    You are probably missing some significant portion of the namespace declaration, as discussed here: http://forum.springsource.org/showthread.php?100397-The-prefix-mvc-for-element-mvc-annotation-driven-is-notbound

    It does not effect runtime, but the development environment will suffer with similar problems as you describe.

    I guess it should go this way: http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

    0 讨论(0)
  • 2021-02-02 12:02

    Add: xmlns:p="http://www.springframework.org/schema/p"

    Otherwise xml will not understand the p annotation.

    0 讨论(0)
  • 2021-02-02 12:04

    Changing below code worked for me

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        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
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    

    to below code (imp : check xmlns:context and xmlns:xsi position)

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        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
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    
    0 讨论(0)
  • 2021-02-02 12:05

    This is an IDE Error, Which can be resolved by following to

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

    enter image description here

    0 讨论(0)
  • 2021-02-02 12:12

    try this it worked for me:

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    <context:component-scan base-package="com.mkyong.common.controller" />
    <mvc:annotation-driven />
    

    0 讨论(0)
提交回复
热议问题