前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Error resolving template: template might not exist or might not be accessible是一句缩水报错?

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

作者头像
ydymz
发布2018-09-10 17:24:59
9.6K2
发布2018-09-10 17:24:59
举报
文章被收录于专栏:lgp20151222

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

template might not exist or might not be accessible

翻译过来就是

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

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

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

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

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

不用怕,我有百度。

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

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

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

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

代码语言:javascript
复制
Error resolving template “home”, template might not exist or might not be accessible by any of the configured Template Resolvers
代码语言:javascript
复制
例子之一

@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包就不行了?

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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-07-27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
    • 也就是说 
      • 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
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档