日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

springMVC 不扫描 controller 中的方法

發布時間:2025/3/19 c/c++ 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 springMVC 不扫描 controller 中的方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近把之前的一個Maven項目在一個新的電腦環境上導入Eclipse,啟動時卻發現不掃描 controller 中的方法

下面是正確的 spring-mvc.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:p="http://www.springframework.org/schema/p"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.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"><mvc:annotation-driven /><mvc:resources location="/image/" mapping="/image/**" /><mvc:resources location="/Content/" mapping="/Content/**" /><mvc:resources location="/js/" mapping="/js/**" /><!-- 自動掃描該包,使SpringMVC認為包下用了@controller注解的類是控制器 --><context:component-scan base-package="com.aven.weixiao.controller" /><!--避免IE執行AJAX時,返回JSON出現下載文件 --><bean id="mappingJacksonHttpMessageConverter"class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"><property name="supportedMediaTypes"><list><value>text/html;charset=UTF-8</value></list></property></bean><!-- 啟動SpringMVC的注解功能,完成請求和注解POJO的映射 --><beanclass="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"><property name="messageConverters"><list><ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON轉換器 --></list></property></bean><!-- 定義跳轉的文件的前后綴 ,視圖模式配置 --><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><!-- 這里的配置我的理解是自動給后面action的方法return的字符串加上前綴和后綴,變成一個 可用的url地址 --><property name="prefix" value="/" /><property name="suffix" value=".jsp" /></bean><!-- 配置文件上傳,如果沒有使用文件上傳可以不用配置,當然如果不配,那么配置文件中也不必引入上傳組件包 --><bean id="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><!-- 默認編碼 --><property name="defaultEncoding" value="utf-8" /><!-- 文件大小最大值 --><property name="maxUploadSize" value="10485760000" /><!-- 內存中的最大值 --><property name="maxInMemorySize" value="40960" /></bean></beans>那我遇到這個問題的原因是什么呢?

是因為新配置的環境,缺少很多 jar 包,所以項目導入Eclipse之后, ?這個文件就報 “<mvc:annotation-driven />”?這一句有錯了,

有錯,我也沒多想就先把它給刪除了。

好吧,問題就這樣產生了。

小結

在導入一個項目之后,可能會提示有很多錯誤,但針對一些配置文件,解決的方式不應該是刪除或修改文件中的內容,

而應該先解決依賴等問題,不然像我這種之前沒有問題的項目,就因為換了環境就產生怪問題。

======================文檔信息===========================

版權聲明:非商用自由轉載-保持署名-注明出處

署名(BY) :testcs_dn(微wx笑)

文章出處:[無知人生,記錄點滴](http://blog.csdn.net/testcs_dn)

總結

以上是生活随笔為你收集整理的springMVC 不扫描 controller 中的方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。