Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jsf 2 - Change /javax.faces.resource prefix of resource URLs

When I use

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

or

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

then in html I get something like this

<link type="text/css" rel="stylesheet" href="/appName/javax.faces.resource/styles.css.xhtml?ln=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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...