您的位置:首页 > 编程语言 > Java开发

SpringMVC配置servlet.xml的时候出现的问题

2012-12-24 12:37 309 查看
今天我们学了SpringMVC,老师给我们粘贴了[servlet-name]-servlet.xml文件的头部,即:

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-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.0.xsd">

在启动服务器的时候,有的时候会开启服务器成功,有的时候就会报错,意思是找不到: <mvc:annotation-driven/>

当然,偶尔又不报错,可以正常运行。

在网上我查这种问题,没有人遇到,在群里问,也没有人遇到,挺愁人的,后来我在网上又找到了一个版本的[servlet-name]-servlet.xml的头部文件,最终解决了问题,即:

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- 默认的注解映射的支持 -->

<mvc:annotation-driven/>

<!-- 自动扫描的包名 -->

<context:component-scan base-package="com.springmvc1.controder"></context:component-scan>

希望能够给大家带来帮助

本文出自 “白手起家” 博客,请务必保留此出处http://zhangshuoyin.blog.51cto.com/3305760/1098087
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐