cvc-complex-type.2.4.a:从元素' bean开始发现无效内容:bean'

时间:2017-09-22 14:11:57

标签: java spring servlets xsd

  

' {" http://www.springframework.org/schema/beans":meta," h       ttp://www.springframework.org/schema/beans" ;: constructor-arg," http://www.springframework.org/schema/beans":property," http://www.springframework.org/schema/beans" :限定符," http://www.springframework.or       g / schema / beans":lookup-method," http://www.springframework.org/schema/beans":replacement-method,WC [## other:" http://www.springframework.org/schema/beans" ]}'是预期的。

Tomcat向我显示错误

我的spring-servlet.xml如下所示。我正在使用.3.11.RELEASE版本的springframework。

<?xml version="1.0" encoding="UTF-8"?>
<beans:bean xmlns="http://www.springframework.org/schema/mvc" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xmlns:context="http://www.springframework.org/schema/context" 
            xmlns:beans="http://www.springframework.org/schema/beans" 
            xsi:schemaLocation="
              http://www.springframework.org/schema/mvc 
                http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
              http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-4.3.xsd
              http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">

    <context:component-scan base-package="in.project.*" />


    <annotation-driven/>

    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/views/"/>
        <beans:property name="suffix" value=".jsp"/>
    </beans:bean>

</beans:bean>

1 个答案:

答案 0 :(得分:2)

xml应用程序上下文的根实体是<beans>,而不是<bean>。 所以你可能最终得到

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xsi:schemaLocation="
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
...
</beans:beans>

没有测试但是应该工作。希望有所帮助。