Here is an example showing how you can use MVC annotations to achieve something similar in Spring:
@RequestMapping(method=RequestMethod.POST, value="/multipartexample")
public String examplePost(@ModelAttribute("fileUpload") FileUpload fileUpload){
}
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
public class FileUpload implements Serializable {
private MultipartFile myFile;
public MultipartFile getMyFile() {
return myFile;
}
public void setMyFile(MultipartFile myFile) {
this.myFile = myFile;
}
}
html-, , "myFile". :
<form:form commandName="fileUpload" id="fileUploadForm" enctype="multipart/form-data">
<form:input type="file" path="myFile" id="myFile"/>
</form:form>
@InitBinder , Spring , MultipartFile