转自:https://blog.csdn.net/HaHa_Sir/article/details/79131607

解决springMVC文件上传报错: The current request is not a multipart request

一、问题描述
在使用springMVC做文件上传时,点击"导入" 时页面报错:org.springframework.web.multipart.MultipartException: The current request is not a multipart request
at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.assertIsMultipartRequest(RequestParamMethodArgumentResolver.java:216)
at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.resolveName(RequestParamMethodArgumentResolver.java:167)
at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:89)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)
at org.springframework.w 。。。。

二、代码参考
1、前端代码

<center>
<h1>论文导入页面</h1>
<form action="${ctx}/executeImport" method="post" >
<input type="file" name="article">
<button> 导入 </button>
</form>
</center>

2、后端代码

@RequestMapping(value={"/executeImport"},method=RequestMethod.POST)
public String executeImport(MultipartFile article){
String originalFilename = article.getOriginalFilename();
System.out.println(originalFilename);
return "modules/cms/importArticle";
}
三、解决办法
1、将编码方式 enctype设置为:"multipart/form-data"。
2、如: <form action="${ctx}/executeImport" method="post" enctype="multipart/form-data">

---------------------
作者:HaHa_Sir
来源:CSDN
原文:https://blog.csdn.net/HaHa_Sir/article/details/79131607
版权声明:本文为博主原创文章,转载请附上博文链接!

解决springMVC文件上传报错: The current request is not a multipart request的更多相关文章

  1. SpringMVC文件上传报错org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest

    错误信息: java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to or ...

  2. windows下IIS+PHP解决大文件上传500错问题

    linux下改到iis+php后,上传大于2M就出500错,改了php.ini中的upload_max_filesize也不行,最后解决如下: 第一步:修改php.ini 上传大小限制 (以上传500 ...

  3. .net core 3.0web_razor page项目_使用中间件接受大文件上传报错_httpRequest.Form threw an exception of type Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException_Request body too large

    前言:在web项目的.net framework时文件上传时,自己常用一般处理程序接受上传文件,上传文件的大小限制是可以项目的webconfig里配置.   到core项目使用一般处理程序变成了中间件 ...

  4. 文件上传报错:Unknown: file created in the system's temporary directory

    nginx+php下文件上传成功,但会有错误提示如下: <b>Notice</b>:  Unknown: file created in the system's tempor ...

  5. springboot文件上传报错

    异常信息: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet reques ...

  6. 解决spring mvc 上传报错,Field [] isn't an enum value,Failed to convert value of type 'java.lang.String[]' to required type '

    没有选择附件,但是点击上传按钮的时候会报错. 之前不选择文件,直接上传空文件是可以的,后来不知道改了什么就不行了. 错误信息: -- :: [http--] TRACE org.springframe ...

  7. nodejs文件上传报错总结

    语法: fs.rename(oldPath,newPath,callback) 今天在使用formidable模块做图片上传处理的时候,fs.rename方法的报了一个这样的错:cross-devic ...

  8. spring mvc文件上传报错:Expected MultipartHttpServletRequest: is a MultipartResolver configured?

    报错原因:spring-mvc.xml 的配置文件中,配置文件上传id不为 “multipartResolver” 解决:id 改为 “multipartResolver”

  9. Struts2实现文件上传报错(四)

    1.具体错误如下 2014-5-2 21:38:29 com.opensymphony.xwork2.util.logging.jdk.JdkLogger error 严重: Exception oc ...

随机推荐

  1. 逆向破解学习二之<TraceMe>

    这次在破解TraceMe的时候,我有看过别人的视频.但是我并没有按照别人思路走,而是完全安全自己的思路试了一次.结果破解成功.新手学破解,如果有不对的地方,还请指出来. 004013A0 crackm ...

  2. Educational Codeforces Round 15 D. Road to Post Office 数学

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. neutron routers HA 实验

    测试环境: 5个节点(( controller,2  network,2 compute nodes)) 采用VXLAN+Linux Bridge 1. 确定所有的neutron和nova服务都在运行 ...

  4. 【R】数据导入读取read.table函数详解,如何读取不规则的数据(fill=T)

    函数 read.table 是读取矩形格子状数据最为便利的方式.因为实际可能遇到的情况比较多,所以预设了一些函数.这些函数调用了 read.table 但改变了它的一些默认参数.  注意,read.t ...

  5. 直方图均衡化的 C++ 实现(基于 openCV)

    这是数字图像处理课的大作业,完成于 2013/06/17,需要调用 openCV 库,完整源码和报告如下: #include <cv.h> #include <highgui.h&g ...

  6. DB21019E An error occurred while accessing the directory "/root".

    如果是在Linux上刚装完DB2即刻建立database,可能会遇到错误DB21019E An error occurred while accessing the directory "/ ...

  7. 17 python 内置函数

    内置函数:Python的内部自带的函数 作用域相关: 基于字典的形式获取局部变量和全局变量 globals()——获取全局变量的ha1 locals()——获取执行本方法所在命名空间内的局部变量的字典 ...

  8. JDBC操作简单实用了IOUtils

    package cn.itcast.demo4; import java.io.FileInputStream; import java.io.FileOutputStream; import jav ...

  9. 201621123014《Java程序设计》第九周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 答: 2. 书面作业 本次作业题集集合 1. List中指定元素的删除(题集题目) 1.1 实验总结.并回答: ...

  10. Unity自带寻路Navmesh

    自带寻路Navmesh的三大组件: 1.Nav Mesh Agent:主要挂在寻路物体上 2.Off Mesh Link:实现区域转移功能(例如,有时不一定只是在地面上进行寻路,可能有些高高的平台,平 ...