0
工作,我有以下控制器:RequestParam標註沒有用POST
@RequestMapping(value = { "/member/uploadExternalImage",
"/member/uploadExternalImage" }, method = RequestMethod.POST)
public String handleFileUpload(@RequestParam("url") String url,
Principal principal) throws IOException {
File file = restTemplate.getForObject("url", File.class);
file.toString();
return null;
}
和我有以下的ajax:
$.ajax({
url: 'uploadExternalImage', //Server script to process data
type: 'POST',
success: function() {
},
complete:function(){
$.fancybox.hideLoading();
},
// Form data
data: {url: files[0].link},
cache: false,
contentType: false,
processData: false
});
春天日誌我看到
org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'url' is not present
如果我用GET更改ajax方法:
$.ajax({
url: 'uploadExternalImage?url=123', //Server script to process data
type: 'POST',
success: function() {
},
complete:function(){
$.fancybox.hideLoading();
},
error: function (data) {
},
cache: false,
contentType: false,
processData: false
});
它正常工作
如何正確配置彈簧?
是的,這個工作
:
試試這個。但我想要通過身體內的數據 – gstackoverflow
請參閱我的編輯請 –
看看這裏:https://spring.io/guides/gs/handling-form-submission/ – ACV