【问题标题】:Accessing dynamic resource message访问动态资源消息
【发布时间】:2012-08-01 07:49:11
【问题描述】:

在我的 Jsp 中,我有

的单选按钮
typeA

typeB

typeC

typeD 

我使用了以下标签:

<c:forEach var="abcTyp" items="${abcTypeList}">
    <form:radiobutton path="abcType" value="<spring:message code="label.admin.lot.${abcType.value}" />" label="${abcTyp.value}" onclick="actSingStone();"/>
</c:forEach>

但我不想使用“abcTyp.value”作为标签,而是想使用国际化消息表单资源包。

我尝试过使用

<form:radiobuttons path="abcType" value="${abcTypeList}" label="<spring:message code="label.admin.pep.${abcTyp.value}"/>." onclick="actSingStone();"/>

在我提到的资源文件中

label.admin.pep.typeA = some text
label.admin.pep.typeB = some text
label.admin.pep.typeC = some text
label.admin.pep.typeD = some text

但它给出了一个错误“预期的等号”

谁能给我同样的解决方案....??

【问题讨论】:

    标签: java spring jsp spring-mvc internationalization


    【解决方案1】:

    尝试将标签设置为变量并使用它,如下所示

    <c:forEach var="abcTyp" items="${abcTypeList}">
      <c:set var="labelVar">
          <spring:message code="label.admin.lot.${abcType.value}" />
      </c:set>    
      <form:radiobutton path="abcType" label="${labelVar}" value="${abcTyp.value}" onclick="actSingStone();"/>    
    </c:forEach>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-05
      • 1970-01-01
      • 2020-03-16
      • 2012-11-30
      相关资源
      最近更新 更多