JSF EL i18n in CSS files

回眸只為那壹抹淺笑 提交于 2019-12-12 01:26:32

问题


In my html pages I use the Spring message bean like so:

#{ms.my_text_label}

ms is of type ReloadableMessageSourceBundle and will translate my_text_label by looking in some resource bundle files. Can I make it possible to use this in my CSS files as well?


回答1:


Disclaimer: I'm ignoring the Spring WebFlow part in the question and do as if the JSF project doesn't use any Spring artifacts.


You can just use EL in CSS files the usual way if you load the CSS file via <h:outputStylesheet> instead of plain HTML <link rel="stylesheet">:

<h:outputStylehseet name="some.css" />

Note: this doesn't work for JS files, even not the ones loaded via <h:outputScript>. EL is supported in CSS files for actually only one technical reason: being able to reference CSS background images via #{resource} mapping without the need to hardcode whole library and JSF mapping.

See also:

  • How to reference CSS / JS / image resource in Facelets template?
  • How to reference JSF image resource as CSS background image url


来源:https://stackoverflow.com/questions/18700987/jsf-el-i18n-in-css-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!