解决springMVC文件上传报错: The current request is not a multipart request
转自: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的更多相关文章
- 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 ...
- windows下IIS+PHP解决大文件上传500错问题
linux下改到iis+php后,上传大于2M就出500错,改了php.ini中的upload_max_filesize也不行,最后解决如下: 第一步:修改php.ini 上传大小限制 (以上传500 ...
- .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项目使用一般处理程序变成了中间件 ...
- 文件上传报错:Unknown: file created in the system's temporary directory
nginx+php下文件上传成功,但会有错误提示如下: <b>Notice</b>: Unknown: file created in the system's tempor ...
- springboot文件上传报错
异常信息: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet reques ...
- 解决spring mvc 上传报错,Field [] isn't an enum value,Failed to convert value of type 'java.lang.String[]' to required type '
没有选择附件,但是点击上传按钮的时候会报错. 之前不选择文件,直接上传空文件是可以的,后来不知道改了什么就不行了. 错误信息: -- :: [http--] TRACE org.springframe ...
- nodejs文件上传报错总结
语法: fs.rename(oldPath,newPath,callback) 今天在使用formidable模块做图片上传处理的时候,fs.rename方法的报了一个这样的错:cross-devic ...
- spring mvc文件上传报错:Expected MultipartHttpServletRequest: is a MultipartResolver configured?
报错原因:spring-mvc.xml 的配置文件中,配置文件上传id不为 “multipartResolver” 解决:id 改为 “multipartResolver”
- Struts2实现文件上传报错(四)
1.具体错误如下 2014-5-2 21:38:29 com.opensymphony.xwork2.util.logging.jdk.JdkLogger error 严重: Exception oc ...
随机推荐
- 获取浏览器的相关信息(navigator)
* 智能机浏览器版本信息: * */ var browser = { versions: function() { var u = navigator.userAgent + navigator.ap ...
- hdu 5877 Weak Pair dfs序+树状数组+离散化
Weak Pair Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Prob ...
- Python之单例模式总结
一.单例模式 a.单例模式分为四种:文件,类,基于__new__方法实现单例模式,基于metaclass方式实现 b.类实现如下: class Sigletion(objects): import t ...
- Keystone集成LDAP
转自 http://wsfdl.com/openstack/2016/01/13/Keystone%E9%9B%86%E6%88%90LDAP.html 得益于 Keystone 优良的架构,它允许 ...
- js的constructor
js创建一个构造函数,会默认在原型链上添加一个constructor的属性,它保存了构造函数内的代码. 一般情况下我们不需要去改动它,但是有些时候我们会不经意的改写它. 比如下面这个例子: var F ...
- 实时监测contenteditable(可编辑文档)的内容发生改变
如果是文本框用onchange,oninput,onpropertychange都可以实时监控值发生变化,但是div设置了属性contenteditable(可编辑文档)就不管用了. 最简单的方法用o ...
- WebAPI Post请求多参数处理方案
contentType:"application/json"You need to use JSON.stringify method to convert it to JSON ...
- poj2396有源汇上下界可行流
题意:给一些约束条件,要求算能否有可行流,ps:刚开始输入的是每一列和,那么就建一条上下界相同的边,这样满流的时候就一定能保证流量相同了,还有0是该列(行)对另一行每个点都要满足约束条件 解法:先按无 ...
- nyoj-67-三角形面积(S=(1/2)*(x1y2+x2y3+x3y1-x1y3-x2y1-x3y2))
题目链接 /* Name:nyoj-67-三角形面积 Copyright: Author: Date: 2018/4/26 16:44:47 Description: 三角形的三个顶点坐标求其面积的公 ...
- Uncaught TypeError: this.canvas.getContext is not a function
/**************************************************************************** * Uncaught TypeError: ...