博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
解决springMVC文件上传报错: The current request is not a multipart request
阅读量:6905 次
发布时间:2019-06-27

本文共 1619 字,大约阅读时间需要 5 分钟。

转自: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
版权声明:本文为博主原创文章,转载请附上博文链接!

转载于:https://www.cnblogs.com/sharpest/p/10177226.html

你可能感兴趣的文章
CSS3设置Table奇数行和偶数行样式
查看>>
PHP版本过狗Shell
查看>>
BZOJ 2127 happiness ——网络流
查看>>
N皇后问题
查看>>
JavaScript检测数据类型
查看>>
观察者模式
查看>>
《CLR via C#》读书笔记 之 类型基础
查看>>
EXt js 学习笔记总结
查看>>
Vue---父子组件之间的通信
查看>>
第八章:手工建库
查看>>
JavaScript语法
查看>>
js事件浏览器兼容
查看>>
获取贴吧对应页html及写入文件
查看>>
Entity Framework学习初级篇3--LINQ TO Entities
查看>>
android 相对布局
查看>>
SilverLight商业应用程序开发---学习笔记(9)
查看>>
MS DTC 无法正确处理DC升级/降级事件。MS DTC 将继续运行并使用现有的安全设置。...
查看>>
CAN总线基础
查看>>
第3课 QT的诞生和本质
查看>>
CentOS6.8下安装Docker
查看>>