我有一个可以动态编辑的表格-用户可以添加/删除行和信息 结构是这样的: 多维数组中的每个元素都有以下元素:
id_material
id_detail
,以及可以在表单中添加/删除的行:
表格:
<input type="hidden" name="myData[id_material][0]" value="123">
<input type="hidden" name="myData[id_detail][0]" value="456">
<input type="text" name="myData[ime_detail][0][1]" value="foo">
<input type="text" name="myData[quantity][0][1]" value="1">
<input type="file" name="myData[file][0][1]" accept=".pdf, .jpg, .dxf">
<input type="hidden" name="myData[id_material][1]" value="123">
<input type="hidden" name="myData[id_detail][1]" value="456">
<input type="text" name="myData[ime_detail][1][1]" value="foo">
<input type="text" name="myData[quantity][1][1]" value="1">
<input type="file" name="myData[file][1][1]" accept=".pdf, .jpg, .dxf">
<input type="text" name="myData[ime_detail][1][2]" value="bar">
<input type="text" name="myData[quantity][1][2]" value="2">
<input type="file" name="myData[file][1][2]" accept=".pdf, .jpg, .dxf">
我的Spring控制器:
@RequestMapping(value = myURL, method = RequestMethod.POST, consumes = {"multipart/form-data"})
public @ResponseBody error save(ModelMap model, HttpServletRequest req,
HttpSession session, HttpServletResponse resp,
@PathVariable("locale") String loc,
@RequestParam Map<String, Object> params) {
System.out.println("save() method invoked");
return null;
}
但是,提交表单时,永远不会调用controller方法。我试过将参数包装在这样的类中:
public class CustomWrapper {
private Map<String, Object> customMap= new HashMap<String, Object>();
public Map<String, Object> getCustomMap() {
return customMap;
}
public void setCustomMap(Map<String, Object> customMap) {
this.customMap = customMap;
}
}
仍未调用。你们知道如何正确提交表格吗?