控制台给我这个错误
错误:org.springframework.web.servlet.DispatcherServlet - Context initialization failed
第23行来自ServletContext资源的XML文档[/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模板项目。
您发布的文件只有21行,而您给出的错误消息是说第23行无效。假设您在发布文件时丢失了几个换行符,那么看起来您丢失了<beans:beans>
声明的结束标记。在文件末尾添加以下内容,xml语法将有效。
</beans:beans>
你会发现,如果你使用IDE(例如Eclipse)或内置XML验证的文本编辑器(例如带有XML Tools插件的notepad++),编写XML会更容易。这将使您更容易、更快地发现语法错误。