在網上看見一種關于springboot的項目結構,并模仿着寫了一下,導緻無法通路頁面,在網上查閱了相關問題及解決辦法,特此留下記錄。
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Jun 25 9:19:17 CST 2019
There was an unexpected error (type=Not Found, status=404).
No message available
原因1:
Application啟動類的位置不對.要将Application類放在最外側,即包含所有子包
原因:spring-boot會自動加載啟動類所在包下及其子包下的所有元件.
原因2:
在springboot的配置檔案:application.yml或application.properties中關于視圖解析器的配置問題:
當pom檔案下的spring-boot-starter-paren版本高時使用:
spring.mvc.view.prefix/spring.mvc.view.suffix
當pom檔案下的spring-boot-starter-parent版本低時使用:
spring.view.prefix/spring.view.suffix
原因3:
控制器的URL路徑書寫問題
@RequestMapping(“xxxxxxxxxxxxxx”)
實際通路的路徑與”xxx”不符合.