org.springframework.web.multipart.MultipartException: The current request is not a multipart request


今天做圖片上傳的碰到這個問題,查找原因是html請求的方式問題。from中涉及到圖片上傳的就要用post提交方式。否則就會報這個錯誤。如果已經是post的提交方式了還有這個錯。。。還有兩種解決方法。

第一中:在jsp頁面的<head></head>標簽里面加上<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />

原因請看http://www.tuicool.com/articles/FrY7Fv

第二種:在from表單的屬性設置里面加上enctype="multipart/form-data"

原因請看http://zkliqiang.iteye.com/blog/779285

我的不是不是上面的任何一種,原因是前台頁面的工作人員在設計頁面的時候使用了百度的ueditor插件,一個功能全面的文本編輯框的插件。雖然很好用,但是他在ueditor.all.js和ueditor.all.min.js里面把post請求的Content-Type:multipart/form-data二進制傳送方式變成了Content-Type:text/html。

這個原因讓我花費了3個多小時。。。。。。。艹!解決方法很簡單,把他們替換下就行了。

在這里結合網上查詢到的坐下總結,算是做個紀念吧。

1.用ajax提交的時候如果沒有在頁面設置<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />這個也會報這個錯誤。

2.用from提交的話,只要沒有類似於ueditor這樣修改提交的數據傳送格式的插件。並且把提交方式設置成了post,一般就不會再出現這個錯了。

3.如果上面的情況都排除了,那么查看你的插件吧!

 

原文地址


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Current request is not a multipart request 上傳文件Request processing failed;nested exception is org.springframework.web.multipart.MultipartException:Failed to parse multipart servlet request;multipart/form-data request failed.(**沒有權限**) spring boot 線上故障 上傳文件出錯:org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: Unable to process parts as no multi-part configura org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608 org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: 臨時上傳路徑[D:\tomcat\work\Catalina\localhost\ROOT]無效 spring boot 上傳文件出錯:org.springframework.web.multipart.MultipartException: Could not parse multipart s Current request is not a multipart request [WARNING] Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'myFile' is not present]已解決+1 后台報錯:org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file_data' is not present
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM