当前位置:Gxlcms > 数据库问题 > 解决Error resolving template template might not exist or might not be accessible问题

解决Error resolving template template might not exist or might not be accessible问题

时间:2021-07-01 10:21:17 帮助过:10人阅读

thymeleaf + Spring Boot 在开发环境正常,但用jar运行时报错 Error resolving template template might not exist or might not be accessible;

 

这个问题我们都很好明白,就是模板页不存在,但是实际上它能找到模板页,但是在使用th:include标签的时候才会出错,这就是问题的症结所在。

 

其实这个问题也很好解决,我们只需要在引用模板文件的时候不用”/”打头就可以了,通过类似相对路径的方式来引用,但是需要说明的是,这里的相对路径仍然是相对于模板根目录来做的。

 

@RequestMapping("/view")

public String view()  {

    return "/view";

}

改成

 

@RequestMapping("/view")

public String view()  {

    return "view";

}

就可以了

 

技术图片

解决Error resolving template template might not exist or might not be accessible问题

标签:解决   图片   通过   ima   就是   环境   request   不用   目录   

人气教程排行