1. 程式人生 > >關於異常:This application has no explicit mapping for /error, so you are seeing this as a fallback.

關於異常:This application has no explicit mapping for /error, so you are seeing this as a fallback.

原因1: Application啟動類的位置不對.要將Application類放在最外側,即包含所有子包 原因:spring-boot會自動載入啟動類所在包下及其子包下的所有元件.

原因2: 在springboot的配置檔案:application.yml或application.properties中關於檢視解析器的配置問題: 當pom檔案下的spring-boot-starter-paren版本高時使用: spring.mvc.view.prefix/spring.mvc.view.suffix (預設建立的springBoot使用這種模式) 當pom檔案下的spring-boot-starter-paren版本低時使用: spring.view.prefix/spring.view.suffix

原因3: 控制器的URL路徑書寫問題 @RequestMapping(“xxxxxxxxxxxxxx”) 實際訪問的路徑與”xxx”不符合.,【可以通過在控制器中輸出一句話,來判斷路徑的正確性】

原因4: 如果你的專案是springBoot ,其中打包的方式是war包的形式,控制器的返回值是字串的,需要尋找解析成jsp頁面的時候,一定要注意pom檔案中是否加入了tomcat-embed-jasper 依賴

		<dependency>
		    <groupId>org.apache.tomcat.embed</groupId>
		    <artifactId>tomcat-embed-jasper</artifactId>
		    <version>9.0.12</version>
		</dependency>