我使用的是 Spring 3.1.0 版本。但是由于 dispatcher-servlet.xml,我在部署时遇到错误。这是我正在使用的代码:
<?xml version="1.0" encoding="UTF-8"?>
<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/spring-beans-3.1.xsd">
<context:component-scan base-package="com.mycompany.cart" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
错误是:
Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 93; cvc-elt.1: Cannot find the declaration of element 'beans'.. Please see server.log for more details.
我试图找到正确的 bean 文件但没有成功。你们能告诉我应该在哪里根据我的春季版本搜索配置文件。