我当前正在使用 resourcesBundle 变量来获取 JSF 代码中的文本值,例如像这样:
<h:outputText value="#{resourceBundle.welcomeMessage}" />
有没有办法将消息 key 放入变量中,并将其作为资源包的动态参数提供?我希望能够做这样的事情:
<c:set var="name" value="#{'welcomeMessage'}" />
<h:outputText value="#{resourceBundle.get(name)}" />
最佳答案
资源包采用动态参数。这是我的项目的片段:
<f:loadBundle basename="#{siteName}" var="bundle"/>
....
<h:dataTable value="#{summary.restrictionList}" var="restrictionList" cellspacing="0" cellpadding="0">
....
<h:outputFormat value="#{bundle['summary.label.blockcodemsg']}">
<f:param value="#{restrictionList['lastFourDigits']}"/>
<f:param value="#{bundle[restrictionList['optionDesc']]}"/>
<f:param value="#{bundle[restrictionList['optionResolutionDesc']]}"/>
</h:outputFormat>
....
关于java - ResourceBundle 的变量查找参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5104656/