【发布时间】:2017-04-02 09:06:16
【问题描述】:
我目前正在研究 spring,我对这个框架非常陌生。我已经添加了所有需要的spring jar,并编写了以下spring-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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.quiz_mcq.controller, com.quiz_mcq.service, com.quiz_mcq.dao"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
我的代码在有互联网连接时工作正常,但在我没有连接到互联网时出现故障。并给出以下错误。
来自 ServletContext 资源 [/WEB-INF/spring->dispatcher-servlet.xml] 的 XML 文档中的第 12 行无效;嵌套异常是 org.xml.sax.SAXParseException;行号:12;列号:109; cvc-complex-type.2.4.c:匹配的通配符是严格的,但找不到元素'context:component-scan'的声明。
我在这里做错了什么?
任何人都可以告诉我解决方案需要做什么才能离线完成项目吗?
【问题讨论】:
标签: java xml spring spring-mvc