我正在尝试将嵌套对象与 Spring 3 绑定,但我遇到了问题。
JSP:
<portlet:actionURL var="formAction" />
<form:form id="add-objects-form" method="post" action="${formAction}">
<input name = "obj.a"...>
<input name = "obj.b"...>
<input type = "file" multiple="multiple" name="file"/>
</form>
表单对象:
class FormObject{
private final static Logger logger = ...
private MultipartFile file
private Obj obj
...getters and setters
}
控制器:
@RequestMapping(method = RequestMethod.POST)
public void uploadDocument(@ModelAttribute FormObject formObject, BindingResult results ) {
}
formObject
得到obj.a
and obj.b
,但file
始终为空。