解决springboot MultipartFile文件上传遇到的问题

发布时间:2020-09-16 06:41:11 作者:befroe_You
来源:脚本之家 阅读:627

1.ajax传过去的参数在controller接受不到

解决:在contoller中增加@RequestParam

例如:saveUploadFile( @RequestParam("file") MultipartFile file,HttpServletRequest request)

2.org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file' is not present

将ajax 请求的contextType 改成是“multipart/form-data; charset=utf-8”,原来是“text/html; charset=UTF-8”格式都是不对的。还是会出现问题,最后改到 contentType: false,请求不使用contentType

3.org.thymeleaf.exceptions.TemplateInputException: Error resolving template "test/upload", template might not exist or might not be accessible by any of the configured Template Resolvers

解决:是contorller层没有返回数据,要么返回String 直接指向页面,要么返回数据值输出

总结

以上所述是小编给大家介绍的解决springboot MultipartFile文件上传遇到的问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对亿速云网站的支持!

推荐阅读:
  1. SpringBoot入门十九,简单文件上传
  2. SpringBoot2 整合 FastDFS 中间件,实现文件分布式管理

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

spring boot multipartfile

上一篇:java为何不能多继承的原因详解

下一篇:python批量设置多个Excel文件页眉页脚的脚本

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》