Springboot项目打包后的页面丢失问题(thymeleaf报错)

遇到的问题目前找到两种:

  • 返回视图路径以/开头,例如 /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>

总结:在代码编写的过程中,要注意规范书写习惯,避免不必要的问题发生。



posted @ 2019-04-27 14:47  清晨的第一抹阳光  阅读(1393)  评论(2编辑  收藏  举报