无法在任何资源加载器中找到资源 'http://***.inc'

unable to find resource 'http://***.inc' in any resource loader

这是我的 Velocity 模板之一的一部分。

#if($!user.type==2)
    <div class="main-site-styles">
        #include('http://***/ca/88/4-9924.inc')
    </div>
#end

当我 运行 它时,IDE 控制台给出

[http-apr-80-exec-4] ERROR apache.velocity   (CommonsLogLogChute.java:96)     - ResourceManager : unable to find resource 'http://***/ca/88/4-9924.inc' in any resource loader.

URL用浏览器访问就可以了。不知道我的velocity里忘记写什么配置了

Velocity 引擎通过使用抽象 class ResourceLoader 的实现来完成模板加载/解析作业。默认实现是从文件系统加载资源。

我认为您打算为 URLResourceLoader as you want to load the templates from filesystem and remote locations as well. That said if you reference the source 提供自定义行为,您应该能够实现按您希望的方式运行的自定义 ResourceLoader。

一个选项,glom URLResourceLoader 中的大部分代码,并更改它确定要从 filesystem/remote 个位置加载的模板内容的方式。

我会将打开流的所有 material 转储到模板,因为您将确定要为内容加载的具体位置。

希望能提供足够的帮助以推进。我建议也将其放入调试器中,并确定哪些内容已传递给相关加载方法,哪些未传递给相关加载方法。