98 Star 573 Fork 123

闲.大赋(李家智) / Beetl

 / 详情

有的时候模板文件存在但是无法加载

待办的
创建于  
2020-08-13 16:52

ClasspathResourceLoader 的 exist方法,判断模板文件是否存在,有的时候,
URL url = this.classLoader.getResource(path);
if (url == null) {
url = this.classLoader.getClass().getResource(path);
}
上面执行还是会是null,path的开头是个 / /meta-info/resources/xx.html 如果path开头不是斜杠即可读取到文件 即:meta-info/resources/xx.html
所以加上
if (url == null) {
String tempPath = path.substring(1);
url = this.classLoader.getResource(tempPath);
}
这样就可以了。
上次出这个问题自己研究了好久,问题解决了,特来通知下。
我通过自定义了一个FhsBeetlClasspathResourceLoader 和 FhsBeetlResource 来解决的此问题。

评论 (0)

fhs_opensource 创建了任务
fhs_opensource 关联仓库设置为闲.大赋/Beetl
展开全部操作日志

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
339743 fhs opensource 1602843222
Java
1
https://gitee.com/xiandafu/beetl.git
git@gitee.com:xiandafu/beetl.git
xiandafu
beetl
Beetl

搜索帮助