遇到的問題目前找到兩種:
- 返回視圖路徑以
/
開頭,例如/test/hello
- 在thymeleaf頁面中,引入的頁面以
/
開頭,例如:<footer th:replace="/index::footer"></footer>
@GetMapping("/about-us") public String sysInfo(){ return "students/about-us"; }
錯誤寫法:(不要在前面加入"/")
return "/students/about-us";
引入公共模板時,也不要加''/'
正確寫法:
<header th:replace="main/sys-public :: stu-header"></header>
總結:在代碼編寫的過程中,要注意規范書寫習慣,避免不必要的問題發生。