1、最常用的配置
spring.mvc.view.prefix=/somePath/
spring.mvc.view.suffix=.html
這樣控制器傳回的視圖名字就直接根據字首字尾配置去找到頁面。
2、但是springboot自動配置配置好的mvc,字首和字尾是空的,@RequestMapping 傳回的是什麼, 那麼boot 就直接查找那個view, 沒有字首和字尾 ,這樣的就直接去靜态資源目錄下找,springboot的靜态資源目錄預設有:
3、當使用Thymeleaf模闆引擎的時候(springboot官方推薦使用的模闆引擎,不推薦使用jsp)
此時@RequestMapping 傳回的視圖名直接從 classpath:/templates/ 目錄下查找,可以看到源碼裡面,Templates的自動配置
尚矽谷springboot的視訊教程可參考下:https://download.csdn.net/download/fxxashelly/11205513