转自: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. QT 事件处理 KeyPressEvent 和 定时器时间 Timer

    1. 按键事件响应, 两种方法,一种直接处理Event,过滤出KeyPress,另一种直接处理KeyPressEvent. bool Dialog::event(QEvent *e) { if( e- ...

  2. 简述redux(1)

    简述redux(1) 概念: 是一个有用的架构,应用场景一般为:多交互.多数据源.如: 某个组件的状态需要共享 某个状态需要在任何地方可以看到 一个组件需要改变全局状态. 一个组件需要改变另一个组件的 ...

  3. 论文笔记 — L2-Net: Deep Learning of Discriminative Patch Descriptor in Euclidean Space

    论文: 本文主要贡献: 1.提出了一种新的采样策略,使网络在少数的epoch迭代中,接触百万量级的训练样本: 2.基于局部图像块匹配问题,强调度量描述子的相对距离: 3.在中间特征图上加入额外的监督: ...

  4. Hive group by实现-就是word 统计

    准备数据 SELECT uid, SUM(COUNT) FROM logs GROUP BY uid; hive> SELECT * FROM logs; a 苹果 5 a 橙子 3 a 苹果 ...

  5. BEC listen and translation exercise 13

    The old lady sits on a mobile chair every morning. He got a large fortune when his father died, but ...

  6. boost bind function用法说明

    目录(?)[+] 1 bind/function 引 (1)头文件 bind函数#include <boost/bind.hpp> function使用头文件#include <bo ...

  7. Linux中sort和uniq关于排序去重的那些用法

    相信在Linux下对文件操作经常会用到sort和uniq命令,下面系统的介绍一下这两个命令的用法. sort命令是在Linux里非常有用,它将文件进行排序,并将排序结果标准输出.sort命令既可以从特 ...

  8. POJ2411Mondriaan's Dream(DP+状态压缩 or 插头DP)

    问题: Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after prod ...

  9. Too Rich(贪心加搜索)

    个人心得:10月份月赛题目,很low,就过了一道水题而且是把所有猜测都提交才过的.这段时间不知道忙什么去了, 也没怎么刷题感觉自己越来越差,还不如新来的大一学弟呢,别人起码天天刷代码到半夜,比起刚在区 ...

  10. VS软件版本号定义、规则和相关的Visual Studio插件

    http://blog.csdn.net/cnhk1225/article/details/37500593 软件版本号主要标识了软件的版本,通过其可以了解软件.类库文件的当前版本,使得软件版本控制有 ...