开发者

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

开发者 https://www.devze.com 2023-03-30 06:50 出处:网络
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\"/>

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

精彩评论

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