網站首頁 編程語言 正文
1、檢查URL是否會被springmvc攔截
首先檢查訪問路徑URL是否正確被springmvc攔截,這個URL和web.,xml中對springmvc的配置有關。
2、檢查Controller層是否使用@Controller注解
檢查是否在Controll層使用@Controller注解來將其標注為組件;
只有使用了@Controller標注的Controller層才能被Springmvc識別.
3、檢查是否配置了<context:component-scan/>和<mvc:annotation-driven/>(springmvc.xml中)
3.1、檢查是否配置了<context:component-scan/>
????????1、<context:component-scan/>是用來指明讓springmvc容器去哪里掃描@Controller注解,只有springmvc找到了@Controller注解,springmvc才能進入Controller.????????2、配置方式為:<context:component-scan base-package="com.taotao.controller" />?
3.2、檢查<context:component-scan/>是否配置正確
????????1、Base-package后面如果寫成”com.taotao.controller.*”是錯誤的(不帶*,定位到包即可).????????2、Base-package后面的路徑指的是Controller層所在的包,如圖,注意路徑一定要寫對.
3.3、檢查是否配置了<mvc:annotation-driven/>
<mvc:annotation-driven/>相當于注冊了DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter兩個bean,配置一些messageconverter。即解決了@Controller注解的使用前提配置。配置方式為:<mvc:annotation-driven />ps:<mvc:annotation-driven/>和<context:component-scan/>不分先后順序
4、檢查是否正確讀取Springmvc的配置文件(web.xml中)
4.1、如果沒有配置<init-param></init-param>
????????那么spring容器會自動去WEB-INF目錄下掃描一個叫SpringMVC-servlet.xml的配置文件來加載springmvc容器.4.2、如果如下圖配置了<init-param></init-param>
????????重點檢查一下是否classpath后面的路徑書寫的有錯誤.注意:
????????1.只有成功讀取到springmvc的xml配置文件,才能讓spring容器加載springmvc容器,然后才能識別@Controller注解并執行標注的Contoller層
????????2.<param-name></param-name>之間的contextConfigLocation是固定的
PS:web.xml加載spring容器的xml配置文件時,<param-name></param-name>之間的contextConfigLocation也是固定的.
5、檢查是否成功加載spring容器
如果spring容器都未成功加載,那么肯定無法成功加載springmvc容器。
5.1、檢查spring容器的監聽是否正常啟動
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
5.2、檢查是否正確讀取了spring容器的xml配置文件
??
注意:再次強調,<param-name>標簽中的contextConfigLocation是固定的,書寫錯誤會報錯
原文鏈接:https://gaodengwen.blog.csdn.net/article/details/132713697
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2022-06-27 Python實現從文件中加載數據的方法詳解_python
- 2022-09-01 詳解C語言中for循環與while循環的用法_C 語言
- 2022-12-04 pytorch從頭開始搭建UNet++的過程詳解_相關技巧
- 2022-05-10 remote: error: GE007: Your push would publish a pr
- 2022-08-31 Flask接收上傳圖片方法實現_python
- 2023-05-17 Android?Lock鎖實現原理詳細分析_Android
- 2024-01-09 使用<scope>import</scope>解決Maven項目單繼承問題
- 2022-05-20 ElasticSearch 7.X系列之:Centos7中常見啟動報錯以及解決方法
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支