Thymeleaf模板项目部署到正式服(Window环境)报错template might not exist or might not be accessible by any of the con

前景

最近在做一个项目的管理系统,本地运行的一切正常,到了要上交任务的时刻了,兴高采烈地准备迎接最美好的周五,额,额,可是人生总要经历点啥挫折的样子,部署到 正式服武器上 ,其中有2个界面 , 响应code 500 报错信息如本文 的标题 所述。第一反应,比对了好几遍 正式环境和 本地开发环境 各种 的配置,DB 是否一样,额, 结果都是 一样的。。。继续找Bug 。。。

解决办法

最后发现这两个界面,就在 跳转的那个方法,我返回的视图 字符串 ,第一个字符是 【/】,其它的界面都没有。

Thymeleaf模板项目部署到正式服(Window环境)报错template might not exist or might not be accessible by any of the con

也因此,解决办法,也就是去掉 /

思考

  • 为什么不需要前面斜杠
    咋thymeleaf 通过返回的String 匹配到对应的 模板文件,是在返回String 的前后追加前缀和后缀
    前缀默认为:classpath:/templates/
    Thymeleaf模板项目部署到正式服(Window环境)报错template might not exist or might not be accessible by any of the con后缀默认为: .html
    Thymeleaf模板项目部署到正式服(Window环境)报错template might not exist or might not be accessible by any of the con
    由于前缀了 已经有一个斜杠了,所以 返回的String 前面不要重复了。