1.ajax傳過(guò)去的參數(shù)在controller接受不到
解決:在contoller中增加@requestparam
例如:saveuploadfile( @requestparam("file") multipartfile file,httpservletrequest request)
2.org.springframework.web.multipart.support.missingservletrequestpartexception: required request part 'file' is not present
將ajax 請(qǐng)求的contexttype 改成是“multipart/form-data; charset=utf-8
”,原來(lái)是“text/html; charset=utf-8”格式都是不對(duì)的。還是會(huì)出現(xiàn)問(wèn)題,最后改到 contenttype: false,請(qǐng)求不使用contenttype
3.org.thymeleaf.exceptions.templateinputexception: error resolving template "test/upload", template might not exist or might not be accessible by any of the configured template resolvers
解決:是contorller層沒(méi)有返回?cái)?shù)據(jù),要么返回string 直接指向頁(yè)面,要么返回?cái)?shù)據(jù)值輸出
總結(jié)
以上所述是小編給大家介紹的解決springboot multipartfile文件上傳遇到的問(wèn)題,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)服務(wù)器之家網(wǎng)站的支持!
原文鏈接:https://blog.csdn.net/befroe_You/article/details/81325479