如何在JSF 1.x中包含相对于上下文路径的CSS? [英] How to include CSS relative to context path in JSF 1.x?
本文介绍了如何在JSF 1.x中包含相对于上下文路径的CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在JSF 1.1中包括相对于上下文路径的CSS样式表?
How can I include CSS stylesheets relative to context path in JSF 1.1?
<link href="{CONTEXT}/css/style.css" rel="stylesheet" type="text/css"/>
就像我们在 JSF2 中使用的一样
Like we use in JSF2.
<link href="#{resource['css:styles.css']}" rel="stylesheet" type="text/css"/>
推荐答案
取决于所使用的视图技术:
Depends on the view technology being used:
如果是JSP(X),请使用${pageContext.request.contextPath}
:
If JSP(X), use ${pageContext.request.contextPath}
:
<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css"/>
如果Facelets 1.x是,请使用#{facesContext.externalContext.requestContextPath}
:
If Facelets 1.x, use #{facesContext.externalContext.requestContextPath}
:
<link href="#{facesContext.externalContext.requestContextPath}/css/style.css" rel="stylesheet" type="text/css"/>
如果Facelets 2.x是,请使用#{request.contextPath}
:
If Facelets 2.x, use #{request.contextPath}
:
<link href="#{request.contextPath}/css/style.css" rel="stylesheet" type="text/css"/>
请注意,JSF 1.x中不支持#{resource}
或<h:outputStylesheet>
.
这篇关于如何在JSF 1.x中包含相对于上下文路径的CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文