【发布时间】:2017-02-14 12:20:56
【问题描述】:
我正在尝试通过参数将 javascript 对象发送到 Struts2 自动完成器操作。但它不起作用。
这是我的代码:
<script>
var nameList = new Array();
function func1(element)
{
console.log(element.value);
var index = nameList.indexOf(element.value);
element.checked ? nameList.push(element.value) : nameList.splice(index,1);
console.log(nameList.length+"---- "+nameList);
}
</script>
<s:form name="baseForm" id="baseForm">
<table width="100%" >
<tr>
<td ><s:text name="Units" /></td>
<td>
<s:iterator value="units" status="itr" id="un">
<input type="checkbox" onclick="func1(this)"
name="unitList[<s:property value="#itr.index"/>]"
value="<s:property value="#un" />" />
</s:iterator>
</td>
</tr>
<tr>
<td ><s:text name="Groups"/></td>
<td width="80%">
<sd:autocompleter href='get_groups.action?unitList=%{nameList}' id='unitAutoComplete' name='unitGroup' loadOnTextChange='true'
loadMinimumCount='1' showDownArrow='false' autoComplete='false' />
</td>
</tr>
</table>
</s:form>
根据选择的单位,组应该被填充到自动完成器中。
所以我的第一个问题是 是否可以通过参数将 javascript 对象发送到 struts2 动作?
如果是,请建议我如何将 javascript 对象作为参数传递。
【问题讨论】:
标签: javascript jsp autocomplete struts2