1
我已经看到相当数量的线程处理文件上传时出现错误的请求错误,但与其他人不同,我相信Spring不会出错在这里,因为我可以通过上传文件卷曲没有问题:curl -X POST -v http://localhost:8080/rest/datasets/ -T test.xlsx
ExtJS上传文件结果为错误请求错误:所需的MultipartFile参数“文件”不存在
ExtJS的上传:
{
xtype: 'filefield',
fieldLabel: 'Select file',
name: 'file',
fieldName : 'file',
listeners: {
change: function(filefield, value, eOpts) {
var form = filefield.up('form').getForm();
form.submit({
url: '/rest/datasets',
headers : {
'Accept' : '*/*',
'Content-Type' : 'multipart/form-data'
},
waitMsg: 'Uploading'
});
}
}
}
春季控制器
@RestController
@RequestMapping("rest/datasets")
public class DatasetController {
@RequestMapping(method = RequestMethod.POST)
public String uploadFile(
@RequestParam("file") MultipartFile file) {
...
}
}
我使用ExtJS 6.0.1和Spring Boot 1.3.3