我成功地能够使用带有ajax.PFB的Spring MVC多部分文件上传文件代码片段:
JSP:
$.ajax(
{
contentType: false,
type: 'post',
url: 'showUploadPage.htm',
enctype: 'multipart/form-data',
processData: false,
async: true,
data: formData,
success: function(response) {
}}) ;
控制器:
@RequestMapping(value = "/showUploadPage.htm", method = RequestMethod.POST)
@ResponseBody
public DisbursementUploadResponse showUploadPageDo(final HttpServletRequest httpRequest, DisbursementFile disbursementFile, BindingResult bindingResult) {
1- file upload
2- data validation
3- data insertion in db
}
由于我的文件上传方法有3个步骤。所以我试图在jsp中向用户显示这三个步骤的状态但没有成功。请确认是否可以通过ajax和spring,因为我是这些中的新手如果有任何帮助材料,也可以分享。