[英]Error: cvc-elt.1: Cannot find the declaration of element 'beans'
I cannot get rid of this error:我无法摆脱这个错误:
cvc-elt.1: Cannot find the declaration of element 'beans'.
cvc-elt.1:找不到元素“beans”的声明。
I am running my web project on Tomcat 9. I have tried all the ways mentioned on stackoverflow, still unable to deal with it.我在Tomcat 9 上运行我的web 项目。我已经尝试了stackoverflow 上提到的所有方法,仍然无法处理它。 I guess it has something to do with the Spring 5.
我想这与Spring 5有关。
Here is my code:这是我的代码:
<?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>
and below is the exception I am getting:以下是我得到的例外:
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)
Change改变
xmlns:schemaLocation="
to到
xsi:schemaLocation="
See also xmlns, xmlns:xsi, xsi:schemaLocation, and targetNamespace?另请参见xmlns、xmlns:xsi、xsi:schemaLocation 和 targetNamespace?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.