简体   繁体   中英

cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans:bean'

One of '{" 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 ":qualifier, " http://www.springframework.or g/schema/beans":lookup-method, " http://www.springframework.org/schema/beans ":replaced-method, WC[##other:" http://www.springframework.org/schema/beans "]}' is expected.

Tomcat is showing me above error

My spring-servlet.xml is given below. I am using .3.11.RELEASE version of 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>

The root entity of the xml application context is <beans> , not <bean> . So you might end up with

<?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>

Haven't tested is but should work. Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM