开发者

How to include CSS relative to context path in JSF 1.x?

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

Like we use in JSF2.

<link href="#{resource['css:styles.css']}" rel="stylesheet" type="text/css"/>


Depends on the view technology being used:

If JSP(X), use ${pageContext.request.contextPath}:

<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css"/>

If Facelets 1.x, use #{facesContext.externalContext.requestContextPath}:

<link href="#{facesContext.externalContext.requestContextPath}/css/style.css" rel="stylesheet" type="text/css"/>

If Facelets 2.x, use #{request.contextPath}:

<link href="#{request.contextPath}/css/style.css" rel="stylesheet" type="text/css"/>

Note that there's no support for #{resource} nor <h:outputStylesheet> in JSF 1.x.


I'm using JSF 2.2 with mojarra 2.2.

#{facesContext.externalContext.requestContextPath}

solves the problem for me; I was using a facelet (.xhtml).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜