我正在 OmniFaces 中尝试 UnmappedResourceHandler
,最初我将所有资源放在如下目录结构下:
WebContent
|-- resources
| `-- default
| `-- 1_0
| |-- css
| | `-- style.css
| |-- img
| | `-- logo.png
| `-- js
| `-- script.js
UnmappedResourceHandler
不适用于版本控制,相反,它可以工作:
WebContent
|-- resources
| `-- default
| |-- css
| | `-- style.css
| |-- img
| | `-- logo.png
| `-- js
| `-- script.js
我没有在任何地方读到它不起作用,所以我想知道我是否遗漏了一些东西?
谢谢
最佳答案
And the following CSS file reference (note: the library is not supported by the UnmappedResourceHandler! this is a technical limitation, just exclusively use name):
<h:outputStylesheet name="css/style.css" />
技术限制是否则无法从 CSS 文件内部相对引用资源。使用库时,路径 /default
将被移动到查询参数 ?ln=default
,然后 CSS 文件将在错误的相对文件夹中查找相对图像引用/resources/css
而不是/resources/default/css
。
您有 2 个选择:
手动将版本附加到查询字符串。
<h:outputStylesheet name="default/css/style.css?#{app.version}" />
您甚至可以为此编写另一个自定义资源处理程序。
使用基于文件名的版本控制。
WebContent |-- resources | `-- default | |-- css | | `-- style.css (this is a folder!) | | `-- 1_0.css | |-- img | | `-- logo.png (this is a folder!) | | `-- 1_0.png | `-- js | `-- script.js (this is a folder!) | `-- 1_0.js :
只是更丑而已。
无论如何,请随意删除最后的 /default
文件夹。
关于jsf - UnmappedResourceHandler 是否适用于库版本控制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27864398/