当前位置: 首页 > 知识库问答 >
问题:

CVC-complex-type2.4.a:发现以元素“beans:bean”开头的内容无效

王英彦
2023-03-14

需要“{”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.org/schema/beans“:lookup-method,”http://www.springframework.org/schema/beans“:replaced-method,

Tomcat显示我上面的错误

下面给出了我的spring-servlet.xml。我使用的是SpringFramework的.3.11.Release版本。

<?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个答案

鲁鹤轩
2023-03-14

xml应用程序上下文的根实体是 ,而不是 。所以你最后可能会

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

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

 类似资料: