解決springboot MultipartFile文件上傳遇到的問題
1.ajax傳過去的參數(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 請求的contextType 改成是“multipart/form-data; charset=utf-8”,原來是“text/html; charset=UTF-8”格式都是不對的。還是會出現(xiàn)問題,最后改到 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層沒有返回數(shù)據(jù),要么返回String 直接指向頁面,要么返回數(shù)據(jù)值輸出
總結(jié)
以上所述是小編給大家介紹的解決springboot MultipartFile文件上傳遇到的問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
解決springboot配置logback-spring.xml不起作用問題
這篇文章主要介紹了解決springboot配置logback-spring.xml不起作用問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-11-11
Java 使用Axis調(diào)用WebService的示例代碼
這篇文章主要介紹了Java 使用Axis調(diào)用WebService的示例代碼,幫助大家更好的理解和使用Java,感興趣的朋友可以了解下2020-09-09
詳解Spring-Boot集成Spring session并存入redis
這篇文章主要介紹了詳解Spring-Boot集成Spring session并存入redis,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05

