Struts 2 中的下拉菜单 [英] Drop-Down in Struts 2

查看:33
本文介绍了Struts 2 中的下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有键值对的映射.我想在下拉列表中显示键和要发送到服务器以识别所选内容的值.

I have a map with key-value pairs. I want to display the key on a drop-down and value to be sent to server for identifying what is selected.

我正在使用 Struts2.我尝试将 Map 放在 标签 list 中,但是它在下拉列表中显示了值.

I am using Struts2. I tried putting the Map in <s:select> tags list, however it shows the values in the dropdown.

推荐答案

使用 listKeylistValue 属性标记以从对象列表中获取属性.

Use listKey and listValue attributes of <s:select> tag to get properties from list of objects.

为了交换映射中的键和值,将 value 放在 listKey 中,将 key 放在 listValue 中.

In order to swap keys and values in map put value in listKey and key in listValue.

<s:select list="someMap" listKey="value" listValue="key"/>

这篇关于Struts 2 中的下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆