Error resolving template: template might not exist or might not be accessible是一句缩水报错?

thymeleaf在开发的时候本地调试正常,但是在测试环境打成jar包就报这个错误了。

template might not exist or might not be accessible

翻译过来就是

模板可能不存在或者无法连接

这时候我在测试环境直接用静态资源找,是可以找到的。但是,走springmvc的话,就会报这个错误。

那么,很明显thymeleaf这个报错有问题。

完蛋啊,报错有问题的话,我怎么定位错误啊!!!

然后,我就逻辑短路了....

不用怕,我有百度。

直接用 template might not exist or might not be accessible去百度,然后找到的答案。大多数是这样的

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

呃,问题是解决了,但是,我一直都是个钻牛角尖的人,,,

后面在一个远古的类似的报错推出了我想要的结果

Error resolving template “home”, template might not exist or might not be accessible by any of the configured Template Resolvers
例子之一

@RequestMapping(value = "/main") public String toMain() { String page = "/main"; return page; }

其中的any of the configured Template Resolvers,指的就是全部的page
翻译过来就是 配置的模板解析器

那么显然就是/main出错了,根据springboot的默认thymeleaf配置,应该改成main
这么说的话thymeleaf报错没错啊,只是缩水了

也就是说 

template might not exist or might not be accessible

这句异常全名可能是

template might not exist or might not be accessible by any of the configured Template Resolvers

可能国外的人以前老遇到这问题,已经一眼就知道说的是什么意思,所以thymeleaf就省略了后面那一串,,,,

那问题来了,为什么开发可以加/,jar包就不行了?

找了很久都没找到一个合适的解释啊,求大神解释一下....

猜你喜欢

转载自www.cnblogs.com/ydymz/p/9378943.html
今日推荐