Java 变量在使用getText时具有空值,但在呈现radiobutton时不具有空值

Java 变量在使用getText时具有空值,但在呈现radiobutton时不具有空值,java,struts2,Java,Struts2,我正在尝试在Struts2 web应用程序中呈现一些单选按钮 每个单选按钮的值是一个整数,其相关标签应为i18n文本,该文本随值的变化而变化。i18n键的格式为Common.eventTypeId.,(例如Common.eventTypeId.28,Common.eventTypeId.29,等等) 但是,当我访问页面时,标签不会被翻译,因为有错误的键:Common.eventTypeId.null。让我困惑的是,用于构建i18n键的同一个变量将ok呈现为单选按钮的值 下面是生成HTML代码的代

我正在尝试在Struts2 web应用程序中呈现一些单选按钮

每个单选按钮的
是一个整数,其相关标签应为i18n文本,该文本随值的变化而变化。i18n键的格式为
Common.eventTypeId.
,(例如
Common.eventTypeId.28
Common.eventTypeId.29
,等等)

但是,当我访问页面时,标签不会被翻译,因为有错误的键:
Common.eventTypeId.null
。让我困惑的是,用于构建i18n键的同一个变量将ok呈现为单选按钮的

下面是生成HTML代码的代码段
eventTypeIds
是一个
列表
,包含3个元素:28、29和31

<s:iterator value="eventTypeIds" var="eTypeId">
    <div class="frm-field">
        <s:set var="label" value="%{getText('Common.eventTypeId.' + eTypeId )}"/>
        <s:radio name="currentActivity.eventTypeId" list="eTypeId" listValue="label"/> 
    </div>
</s:iterator>
这是当前生成的实际HTML:

<div class="frm-field">
    <input type="radio" value="29" checked="checked" id="frm-activity_currentActivity_eventTypeId29" name="currentActivity.eventTypeId">
    <label for="frm-activity_currentActivity_eventTypeId29">Common.eventTypeId.null</label>
</div>
<div class="frm-field">
    <input type="radio" value="28" id="frm-activity_currentActivity_eventTypeId28" name="currentActivity.eventTypeId">
    <label for="frm-activity_currentActivity_eventTypeId28">Common.eventTypeId.null</label>
</div>
<div class="frm-field">
    <input type="radio" value="31" id="frm-activity_currentActivity_eventTypeId31" name="currentActivity.eventTypeId">
    <label for="frm-activity_currentActivity_eventTypeId31">Common.eventTypeId.null</label>
</div>

Common.eventTypeId.null
Common.eventTypeId.null
Common.eventTypeId.null
这将是预期的HTML:

<div class="frm-field">
    <input type="radio" value="29" checked="checked" id="frm-activity_currentActivity_eventTypeId29" name="currentActivity.eventTypeId">
    <label for="frm-activity_currentActivity_eventTypeId29">CAA</label>
</div>
<div class="frm-field">
    <input type="radio" value="28" id="frm-activity_currentActivity_eventTypeId28" name="currentActivity.eventTypeId">
    <label for="frm-activity_currentActivity_eventTypeId28">Practical</label>
</div>
<div class="frm-field">
    <input type="radio" value="31" id="frm-activity_currentActivity_eventTypeId31" name="currentActivity.eventTypeId">
    <label for="frm-activity_currentActivity_eventTypeId31">Non-assessable activity</label>
</div>

民航局
实用的
非评估活动
请注意,使用
eTypeId
变量正确显示整数值,但在构建i18n键时,该变量为null。我错过了什么?我是否误解了s:radio标签的用法?

在使用
eTypeId
标签内的变量之前,您缺少

<s:set var="label" value="%{getText('Common.eventTypeId.' + #eTypeId )}"/>
在使用
标记内的
eTypeId
var之前,您缺少

<s:set var="label" value="%{getText('Common.eventTypeId.' + #eTypeId )}"/>
<s:radio name="currentActivity.eventTypeId" list="eventTypeIds" 
              listValue="%{getText('Common.eventTypeId.' + top)}"/>