2

I'm trying to update a map using struts 2 form. Iterating over the map displays the key value pair correctly, but when I submit the form, map is not getting populated. Key is a string with characters like . and /. Here is an example:

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>

I tried using quotes like this: name="map['%{key}']", but it still doesn't work. I can see from the logs that the ParamsInterceptor is setting the params correctly: map[utilities.student_info.note] => [note]. But the map is empty on the action side. If I use name="map[%{#attr.status.index}]", it populates the map, but the key is an index (map[0] => [note]) which is not right.

Any suggestions would be appreciated. Thanks.

4

1 回答 1

0

这取决于您使用的 Struts2 版本,但 2.3.8map['utilities.student_info.note']不是可接受的参数。尝试map['utilities_student_info_note'],它应该工作。密钥应仅由单词字符组成。

于 2013-10-31T22:58:51.907 回答