简体   繁体   English

多选下拉菜单在Struts 2中突出显示

[英]Multi Select Drop Down Highlighted in Struts 2

Jsp- Jsp-

<s:form action="product">

<s:select label="Select Data"
    cssStyle="width:150; height:73"
    size="6"
    multiple="true"
    headerKey="-1" headerValue="All"
    list="#{'1':'Data1', '2':'Data2', '3':'Data3', '4':'Data4' }"
    name="dataValue"
    value="%{2,3}" />
<s:submit value="save"></s:submit>
</s:form>

Action : 动作:

public class Product {
private String dataValue;
//getter setter
.......
public String execute(){  
                return "success";  
    }

}

Problem : at a time one field is selected only for example i passed value 2,3 then only Data3 is selected but i wants Data2 and Data3 selected 问题:一次仅选择一个字段,例如我传递了值2,3,则仅选择了Data3,但我希望选择Data2和Data3

To pre-select multiple values you need to use list or array for the action property in the value attribute. 要预选多个值,您需要在value属性中为action属性使用list或array。

'1', '2',... are character type values, so you return a character list '1','2',...是字符类型值,因此您返回字符列表

public List<Character> getDataValue(){
  return dataValue;
}

<s:select label="Select Data"
    cssStyle="width:150; height:73"
    size="6"
    multiple="true"
    headerKey="-1" headerValue="All"
    list="#{'1':'Data1', '2':'Data2', '3':'Data3', '4':'Data4' }"
    name="dataValue"
    value="%{dataValue}" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Struts 2中未显示有关选择下拉菜单的错误消息 - Not displaying error message for a select drop down in Struts 2 在Struts + JSP中为下拉列表创建Mysql SELECT语句的逻辑是什么? - What is the logic of creating the Mysql SELECT Statement for drop down in Struts + JSP? 使用JavaScript / JQuery动态添加Struts 2选择下拉列表 - Add Struts 2 select drop down list dynamically using JavaScript/JQuery 在下拉列表中从数据库中检索值( <s:select> )使用Struts 2和Hibernate - Retrieve value from database in drop-down(<s:select>) using Struts 2 and Hibernate JSP下拉列表,默认使用struts在页面加载时选择第一个选项 - JSP drop down list to select first option by default on page load using struts 使用bean对象Struts中的值填充下拉列表 - Populating drop down with values in bean object Struts 如何在 angular js 中使用带有标题的多 select 下拉菜单 - How can I use multi select drop down with headings in angular js 在Struts 2.x的索引页面上填充下拉菜单 - Populating drop down on the index page in Struts 2.x 用jsp,struts2和postgresql填充下拉列表 - Populate drop down list with jsp, struts2 & postgresql 使用 Hibernate 在 Struts 2 中将下拉列表值保存到数据库 - Save drop-down list value to database in Struts 2 with Hibernate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM