Can I use EL for external CSS files with JSF?

前端 未结 6 1106
情歌与酒
情歌与酒 2020-12-19 07:46

In external style sheets of my current JSF project, there are hard-coded links to external resources like

.someId { background-image:url(/context/resources/i         


        
6条回答
  •  臣服心动
    2020-12-19 08:27

    You can use Expression Language (EL) along with the FacesContext to solve the issue. I use this technique frequently.

    background-image: url('#{facesContext.externalContext.requestContextPath}/resources/images/background.gif');
    

    This allows you to take advantage of JSF to provide dynamic content based on application input, or changes.

    This technique works on JSF 1.2 and JSF 2.0

提交回复
热议问题