簡體   English   中英

錯誤:cvc-elt.1:找不到元素“beans”的聲明

[英]Error: cvc-elt.1: Cannot find the declaration of element 'beans'

我無法擺脫這個錯誤:

cvc-elt.1:找不到元素“beans”的聲明。

我在Tomcat 9 上運行我的web 項目。我已經嘗試了stackoverflow 上提到的所有方法,仍然無法處理它。 我想這與Spring 5有關。

這是我的代碼:

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

        <bean id="HandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
        <bean name="/welcome.html" class="com.gontuseries.hellocontroller.HelloController"/>
        <bean id="ViewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <property name="prefix">
                <value>/WEB-INF/</value>
              </property>       
                <property name="suffix">
                <value>.jsp</value>
              </property>   
        </bean> 
</beans>

以下是我得到的例外:

Sep 25, 2018 1:15:46 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet [spring-dispatcher]
org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 6; cvc-elt.1: Cannot find the declaration of element 'beans'.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)

改變

    xmlns:schemaLocation="

    xsi:schemaLocation="

另請參見xmlns、xmlns:xsi、xsi:schemaLocation 和 targetNamespace?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM