今天我們學了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>
希望能夠給大家帶來幫助