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