JSF 资源版本控制 [英] JSF resource versioning

查看:24
本文介绍了JSF 资源版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对应用程序中的资源进行版本控制.

如果我喜欢这个资源/js/1_0_0/mainscript.js

它不起作用.它说 RESOURCE_NOT_FOUND

但是当我喜欢这个时

资源/js/mainscript.js/1_0_0.js

它有效.我不喜欢它以第二种方式组织的方式.第一个看起来很酷.有什么想法吗?

我使用的是 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">

然后我看了 META-INF/resources/primefaces/jquery/jquery.js

他们在那里没有任何版本控制但是它是如何在头部附加 v=2.2.1 的

解决方案

如果我喜欢这个资源/js/1_0_0/mainscript.js

它不起作用.它说 RESOURCE_NOT_FOUND

如果您指定 js 作为库名,这将起作用.

然而,这不是资源库的正确用法.不如介绍一个.

resources/default/1_0_0/js/mainscript.js

那么你可以指定如下:


<块引用>

他们在那里没有任何版本控制但是它是如何在头部附加 v=2.2.1 的

它由 PrimeResource 完成,它通过 ln=primefaces 参数启动资源请求.它的 getRequestPath() 具有以下实现:

@Override公共字符串 getRequestPath() {return super.getRequestPath() + "&amp;v=";+ 常量.VERSION;}

其中 Constants 是 PrimeFaces 特定的常量文件,它随每个 PF 版本更新.

I am trying to put versioning around the resources in an application.

If I do like this resources/js/1_0_0/mainscript.js

It does not work. It says RESOURCE_NOT_FOUND

but when I do like this

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?

I am using Tomcat 7.0, JSF 2.0.9

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">

Then I looked at META-INF/resources/primefaces/jquery/jquery.js

They did not have any versioning in there but how did it append v=2.2.1 in the head

解决方案

If I do like this resources/js/1_0_0/mainscript.js

It does not work. It says RESOURCE_NOT_FOUND

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" />


They did not have any versioning in there but how did it append v=2.2.1 in the head

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() + "&amp;v=" + Constants.VERSION;
}

Where Constants is the PrimeFaces specific constants file which is updated with every PF version.

这篇关于JSF 资源版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆