我已经按照以下Spring MVC教程一直正常工作,直到我部署步骤4.6: Spring MVC step by step tutorial
我得到的错误是:
SEVERE: Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 i
n XML document from ServletContext resource [/WEB-INF/springapp-servlet.xml] is
invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4
.a: Invalid content was found starting with element 'beans'. One of '{"http://ww
w.springframework.org/schema/beans":description, "http://www.springframework.org
/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "htt
p://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springfra
mework.org/schema/beans"]}' is expected.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
eanDefinitions(XmlBeanDefinitionReader.java:369)
答案 0 :(得分:1)
我不知道为什么他们这样表现出来并且老实说你不应该看这样的超级老教程,但解决办法是简单地删除<{p>}中的<beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- the application context definition for the springapp DispatcherServlet -->
<beans> <---remove this guy