本文介绍了更改资源URL的/javax.faces.resource前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用

<h:outputStylesheet library="css" name="styles.css">

<h:graphicImage library="images" name="image.jpg">

然后在html中我得到这样的东西

then in html I get something like this

<link type="text/css" rel="stylesheet" href="/appName/javax.faces.resource/styles.css.xhtml?ln=css" />

,因此用户可以查看用于编写此应用程序的框架.如何避免向用户显示javax.faces.resource/styles.css.xhtml?ln=css,但仍然使用facelets(不是HTML,例如>)?当用户仅将css文件的路径视为resources/css/styles.css

so the user can see which framework was used to write this app. How can I avoid showing javax.faces.resource/styles.css.xhtml?ln=css to the user, but also still using facelets(not html, like <link rel=...>)? It will be good when the user simply will see the path to the css file as resources/css/styles.css

推荐答案

如果不重新实现整个 ResourceHandler 借助 ResourceHandlerWrapper 作为,这并不是一件容易的事.这是 ResourceHandler中的硬编码的public static final字段常量. 类, ResourceHandler#RESOURCE_IDENTIFIER .您可能需要发布功能请求,以使其在外部可配置,就像 NamingContainer 分隔符.

That's not directly possible without reimplementing the entire ResourceHandler with help of a ResourceHandlerWrapper as answered by lu4242 on this question, which is not exactly a trivial job. It's a hardcoded public static final field constant in ResourceHandler class, the ResourceHandler#RESOURCE_IDENTIFIER. You may want to post a feature request to make this externally configureable like as has happened for the NamingContainer separator character during the JSF 1.2 to JSF 2.0 step.

但是您为什么要这样做?还有很多其他事情可以为所使用的框架提供足够的提示.如果JSF可以是请求URL模式(/faces/**.jsf*.xhtml),响应头(X-Powered-By),特定的隐藏表单字段(javax.faces.ViewState),自动生成的客户机ID(通过默认为木库存),使用的JS库(jsf.js)等.

But why would you do this? There are a lot of other things which gives enough hints about the framework used. In case of JSF that can be the request URL pattern (/faces/*, *.jsf or *.xhtml), the response headers (X-Powered-By), specific hidden form fields (javax.faces.ViewState), the autogenerated client IDs (by default woodstocked), the JS libraries used (jsf.js), etcetera.

这篇关于更改资源URL的/javax.faces.resource前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 09:57