java - ResourceBundle 的变量查找参数?

标签 java spring jsf spring-webflow resourcebundle

我当前正在使用 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/

相关文章:

java - 如何配置 JAXB/Moxy 以针对 XML 中可能丢失的数据抛出错误

java - 利用 Hibernate 延迟加载?

javascript - a4j :jsFunction not called from another script

java - 在 jade 中构建具有集成 GUI 的代理

java - 多变量快速排序 [Java]

java - 带有 Autowired 语句的 NullPointerException

html - 无法在 Firefox 上设置数据表边框 css

jsf - 有条件渲染的输入组件不更新值

java - 如何安静 org.w3c.dom.Document?

Spring Boot Jpa JPQL 选择特定列以外的列