1.ajax傳過去的參數在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 請求的contexttype 改成是“multipart/form-data; charset=utf-8
”,原來是“text/html; charset=utf-8”格式都是不對的。還是會出現問題,最后改到 contenttype: false,請求不使用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層沒有返回數據,要么返回string 直接指向頁面,要么返回數據值輸出
總結
以上所述是小編給大家介紹的解決springboot multipartfile文件上傳遇到的問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網站的支持!
原文鏈接:https://blog.csdn.net/befroe_You/article/details/81325479