【发布时间】:2015-08-18 18:08:27
【问题描述】:
控制台向我抛出此错误
错误:org.springframework.web.servlet.DispatcherServlet - 上下文初始化失败
来自 ServletContext 资源的 XML 文档中的第 23 行 [/WEB-INF/spring/appServlet/servlet-context.xml] 无效
这是我的 servlet 上下文文件
<?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:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
<context:component-scan base-package="mvc.test.hib" />
</beans:bean>
我错过了什么?我对使用 spring/hibernate 编程很陌生,有些东西我仍然不太了解
编辑:附加细节,我使用的是 Spring 工具套件,以及默认的 MVC spring 模板项目。
【问题讨论】:
-
最后一行应该是
</beans:beans>而不是</beans:bean>(复数bean) -
@orid 很好。我想知道当文件只有 21 行时,第 23 行可能是坏的。