【问题标题】:cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans:bean'cvc-complex-type.2.4.a:发现以元素“beans:bean”开头的无效内容
【发布时间】:2018-03-04 03:45:13
【问题描述】:

'{"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"]}' 是预期的。

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>

【问题讨论】:

    标签: java spring servlets xsd


    【解决方案1】:

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

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

    尚未测试但应该可以。希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 2011-07-07
      • 2019-01-26
      • 2018-12-23
      • 1970-01-01
      • 1970-01-01
      • 2018-08-24
      相关资源
      最近更新 更多