我有以下选择,即多选
<html:select property="select1" styleId="select1" style="width:330px;" size="6" multiple="true" disabled="true">
<html:optionsCollection property="wo" value="id" label="idAndRef" />
</html:select>
<html:hidden property="select1" styleId="select1"/>
由于选择被禁用,我具有隐藏属性。
由于选择为disabled
var select = document.getElementById('select1');
if (select.disabled) {
// If disabled, do this
var allOptions = new Array;
$('#styleId option').each(function(){
allOptions.push($(this).val());
});
var arrayLength = allOptions.length;
for (var i = 0; i < arrayLength; i++) {
select.options[i].value = allOptions[i]
select.options[i].selected = true;
}
//document.forms[0].styleId.value=allOptions;
return true;
}
但是当我调试并检入服务器时,我得到以下内容作为select1
[[Ljava.lang.String;@42205593]
我不明白为什么上面一个是值而不是字符串数组。
private String[] select1 = new String[] {}; //is how it is declared in struts form.