JSF资源版本控制 [英] JSF resource versioning
问题描述
我试图围绕应用程序中的资源进行版本控制.
I am trying to put versioning around the resources in an application.
如果我喜欢这个资源/js/1_0_0/mainscript.js
If I do like this resources/js/1_0_0/mainscript.js
它不起作用.它说RESOURCE_NOT_FOUND
It does not work. It says RESOURCE_NOT_FOUND
但是当我这样做
resources/js/mainscript.js/1_0_0.js
resources/js/mainscript.js/1_0_0.js
有效.我不喜欢第二种方式的组织方式.第一个看起来很酷.有想法吗?
It works. I do not like the way it is organized in the second way. First one looks cool. Any Idea?
我正在使用Tomcat 7.0,JSF 2.0.9
I am using Tomcat 7.0, JSF 2.0.9
更新:我正在检查primefaces-2-2.1.jar.因为当我检查页面源时,我看到了 /javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=2.2.1>
Update: I was checking primefaces-2-2.1.jar. Since when I checked the page source, I saw this /javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=2.2.1">
然后我看了META-INF/resources/primefaces/jquery/jquery.js
Then I looked at META-INF/resources/primefaces/jquery/jquery.js
他们那里没有任何版本控制,但是它如何在头部附加v = 2.2.1
They did not have any versioning in there but how did it append v=2.2.1 in the head
推荐答案
如果我喜欢这个资源/js/1_0_0/mainscript.js
它不起作用.它说RESOURCE_NOT_FOUND
如果您将js
指定为库名,这将起作用.
This will work if you specify js
as library name.
<h:outputScript library="js" name="mainscript.js" />
但是,这不是资源库的正确用法.而是介绍一个.
However, this is not the proper usage of a resource library. Rather introduce one.
resources/default/1_0_0/js/mainscript.js
然后您可以按以下方式指定它:
Then you can specify it as follows:
<h:outputScript library="default" name="js/mainscript.js" />
他们那里没有任何版本控制,但是它如何将v = 2.2.1附加在头部
这由PrimeResource
完成,它使用ln=primefaces
参数启动资源请求.其getRequestPath()
具有以下实现:
It's done by PrimeResource
which kicks in on resource requests with ln=primefaces
parameter. Its getRequestPath()
has the following implementation:
@Override
public String getRequestPath() {
return super.getRequestPath() + "&v=" + Constants.VERSION;
}
其中Constants
是PrimeFaces特定的常数文件,随每个PF版本更新.
Where Constants
is the PrimeFaces specific constants file which is updated with every PF version.
这篇关于JSF资源版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!