我正在尝试使用struts 2表单更新地图。迭代map可以正确地显示键值对,但是当我提交表单时,map不会被填充。Key是一个字符串,其字符类似于。和/。下面是一个示例:
Map<String, String> map = new HashMap<String, String>();
map.put("utilities.student_info.note", "note");
<s:iterator value="map" var="property" status="status">
<s:property value="%{key}"/>
<s:textarea name="map[%{key}]" value="%{value}" rows="5" cols="60"/>
</s:iterator>我尝试使用这样的引号:name="map['%{key}']",但它仍然不起作用。我可以从日志中看到ParamsInterceptor正在正确地设置参数:map[utilities.student_info.note] => [note]。但是动作方面的地图是空的。如果我使用name="map[%{#attr.status.index}]",它会填充映射,但是键是一个不正确的索引(map[0] => [note])。
如有任何建议,我们将不胜感激。谢谢。
发布于 2013-11-01 06:58:52
这取决于您使用的Struts2版本,但2.3.8版本的map['utilities.student_info.note']不是一个可接受的参数。试一试map['utilities_student_info_note'],它应该可以工作。密钥只能由单词字符组成。
https://stackoverflow.com/questions/11870602
复制相似问题