今天我们学了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>

希望能够给大家带来帮助