如何通过 #include 在 Velocity 宏中包含静态或上传的文件

2024-03-31

我正在尝试通过在随初始请求下载的 HTML 中内嵌一些 CSS 来优化一些移动网页(或更准确地说是服务器请求的数量)。

这些页面由我们基于 Vosao 的 CMS 提供,并使用 Apache Velocity 宏。

正如预期的那样,这工作得很好。

<link rel="stylesheet" type="text/css" media="screen" href="/file/downloads/contact.css" 

这失败了

<style>
#include( "/file/downloads/contact.css" )
</style>

由于 Velocity 找不到该文件,因此输出如下

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource '/file/downloads/contact.css'

这在日志中

org.apache.velocity.runtime.log.CommonsLogLogChute log: ResourceManager : unable to find resource '/file/Downloads/contact.css' in any resource loader.
E 2012-06-20 13:59:19.688
org.apache.velocity.runtime.log.CommonsLogLogChute log: #include(): cannot find resource '/file/Downloads/contact.css', called at vm[line 7, column 3]

我已经阅读了速度文档(关于资源 ROOT 属性),甚至花了一些时间在源代码上。我在加载时尝试过这些属性......但没有运气。

如何让 Velocity 将静态文件包含在我的 /war 目录中,或者获取它以从路径包含?


我已经成功地使用了这样的方法:

<style type="text/css">
  #include("my/path/to/file/file.css")
</style>

也许你的文件路径错误?

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何通过 #include 在 Velocity 宏中包含静态或上传的文件 的相关文章

随机推荐