【问题标题】:Struts2 - s:select tag Value attribute not returning anything inside display tagStruts2 - s:选择标签值属性不返回显示标签内的任何内容
【发布时间】:2019-08-01 15:48:28
【问题描述】:

我们正在从 struts 1 转换为 struts 2。作为其中的一部分。我们在数据库中有一个列表,我们需要在其中显示为下拉列表,并在每行的下拉列表中选择差异值。例如

如果列表包含猫、狗、牛

那么显示标签中的第 1 行应该显示下拉菜单,其中包含使用选项“cat”选择的所有 3 个值

那么显示标签中的第 2 行应显示下拉菜单,其中包含使用选项“dog”选择的所有 3 个值

同样剩余。

我能够获得下拉菜单,但无法预先选择下拉菜单

在 struts 1 中我们有这样的代码(工作代码)

<display:table name="requestScope.channelList" 
            requestURI="/channels.do?method=search" uid="channel">

<display:column title="Channel">
<html:select property="channelCdUpd" value="${channel.channelCd}">
<html:option value="${channel.channelCd}">${channel.channelCd}</html:option>
<html:optionsCollection property="allChannels"/>
</html:select>
</display:column>

Struts 2 我的代码是这样的(新代码)

 <display:table name="requestScope.dfSrcLocChannelList" 
                requestURI="channelsSearch.action" uid="channel"> 
<display:column title="Channel">
    <s:select value="???????"
    headerKey="" headerValue=""
    name="channelCdUpd" list="allChannels" />
 </display:column>
</display:table>

select 中的这个值是我努力正确填充的地方,因为 struts2 不支持这个 ${} 任何帮助将不胜感激。

谢谢

【问题讨论】:

  • 嗯,所以你的问题是如何将表达式语言转换为struts2 对吗?如果是,请尝试使用此代码&lt;s:property value="%{#rowStatus.index}"/&gt;,struts2 使用OGNL 这是reference
  • @vincenzopalazzo 你需要一个迭代器。

标签: struts2


【解决方案1】:

struts 使用 %{...} 表达式。它被称为ognl 值="%{...}"

<s:select label="label blabla"
 name="bean.anyproperty"                      
 list="%{listBean}" listKey="anyproperty"  listValue="anyproperty" 
value="{bean.property}">
</s:select> 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多