转自: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. php/oracle: 解析oracle表中的NCLOB,CLOB字段里面的内容

    php/oracle: 解析oracle表中的NCLOB,CLOB字段里面的内容 假如你的字段名是:passenger_info 字段类型是:NCLOB/CLOB,在读表的时候,需要将 passeng ...

  2. 任务1-1 了解Web基本概念

    1.认识网页 从图中可以看到,网页主要由文字.图像和超链接等元素构成.当然,除了这些元素,网页中还可以包含音频.视频及Flash. 为了快速了解网页是如何形成的,接下来查看一下网页的源代码

  3. U14739 X ask Y III 子区间异或和

    题意:就是求所有子区间的异或和的和 题解:就是算每一位对结果的贡献(最近好像遇到很多次这种题目),先前缀异或,从左向右扫记录二进制前缀的1,0个数,xor[i]==xor[j]^1的时候就加上这一位的 ...

  4. C++中内部类访问外部类的私有成员

    首先,如果不知道什么是内部类InnerClass的话,就没必要往下看了. 尝试在C++中模仿apple objective-c 的Grand Dispatch简化多线程编程时,使用了boost::fu ...

  5. 【Oracle】实现Oracle数据库对象的一键升级

    引言     公司内部的项目比较倾向于将业务逻辑放在oracle存储过程中实现,所以每次项目升级都涉及到很多的oracle表,存储过程等数据库对象的升级.然而采取的升级方式是比较"原始&qu ...

  6. LeetCode OJ:Minimum Size Subarray Sum(最小子数组的和)

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

  7. Jquery中.ajax和.post详解

    之前写过一篇<.NET MVC 异步提交和返回参数> ,里面有一些ajax的内容,但是不深入,这次详细剖析下jquery中$.ajax的用法. 首先,上代码: jquery-1.5.1 $ ...

  8. 洛谷P2706 巧克力

    题目背景 王7的生日到了,他的弟弟准备送他巧克力. 题目描述 有一个被分成n*m格的巧克力盒,在(i,j)的位置上有a[i,j]块巧克力.就在送出它的前一天晚上,有老鼠夜袭巧克力盒,某些位置上被洗劫并 ...

  9. unitychan-crs 头发随动脚本

    // //SpringCollider for unity-chan! // //Original Script is here: //ricopin / SpringCollider.cs //Ro ...

  10. Directx 9 VS2015环境搭建

    安装好Directx9 sdk和vs2015后 打开vs,新建项目 --> c++项目  -->win32控制台应用程序-->空项目 创建项目后,右键项目属性, 包含目录 D:\Pr ...