来源:http://blog.csdn.net/awmw74520/article/details/70230591

SpringBoot做文件上传时出现了The field file exceeds its maximum permitted size of 1048576 bytes.错误,显示文件的大小超出了允许的范围。查看了官方文档,原来Spring Boot工程嵌入的tomcat限制了请求的文件大小,这一点在Spring Boot的官方文档中有说明,原文如下

65.5 Handling Multipart File Uploads
Spring Boot embraces the Servlet 3 javax.servlet.http.Part API to
support uploading files. By default Spring Boot configures Spring MVC
with a maximum file of 1Mb per file and a maximum of 10Mb of file data
in a single request. You may override these values,
as well as the location to which intermediate data is stored (e.g., to
the /tmp directory) and the threshold past which data is flushed to disk
by using the properties exposed in the MultipartProperties class. If
you want to specify that files be unlimited,
for example, set the multipart.maxFileSize property to -1.The multipart
support is helpful when you want to receive multipart encoded file data
as a @RequestParam-annotated parameter of type MultipartFile in a
Spring MVC controller handler method.

文档说明表示,每个文件的配置最大为1Mb,单次请求的文件的总数不能大于10Mb。要更改这个默认值需要在配置文件(如application.properties)中加入两个配置

需要设置以下两个参数

multipart.maxFileSize
multipart.maxRequestSize

Spring Boot 1.3.x或者之前

multipart.maxFileSize=100Mb
multipart.maxRequestSize=1000Mb

Spring Boot 1.4.x或者之后

spring.http.multipart.maxFileSize=100Mb
spring.http.multipart.maxRequestSize=1000Mb

很多人设置了multipart.maxFileSize但是不起作用,是因为1.4版本以上的配置改了,详见官方文档:spring boot 1.4

[转]Spring Boot修改最大上传文件限制:The field file exceeds its maximum permitted size of 1048576 bytes.的更多相关文章

  1. Spring Boot:The field file exceeds its maximum permitted size of 1048576 bytes

    错误信息:The field file exceeds its maximum permitted size of 1048576 bytes原因是因为SpringBoot内嵌tomcat默认所能上传 ...

  2. Spring Boot 在接收上传文件时,文件过大异常处理问题

    Spring Boot 在接收上传文件时,文件过大时,或者请求过大,spring内部处理都会抛出异常,并且捕获不到. 虽然可以通过调节配置,增大 请求的限制值. 但是还是不太方便. 之所以捕获不到异常 ...

  3. 【Spring Boot】关于上传文件例子的剖析

    目录 Spring Boot 上传文件 功能实现 增加ControllerFileUploadController 增加ServiceStorageService 增加一个Thymeleaf页面 修改 ...

  4. Spring Boot 使用 ServletFileUpload上传文件失败,upload.parseRequest(request)为空

    使用Apache Commons FileUpload组件上传文件时总是返回null,调试发现ServletFileUpload对象为空,在Spring Boot中有默认的文件上传组件,在使用Serv ...

  5. spring boot 2.X上传文件限制大小

    Spring Boot 1.3.x multipart.maxFileSize multipart.maxRequestSize Spring Boot 1.4.x and 1.5.x spring. ...

  6. Spring中servletFileUpload完成上传文件以及文本的处理

    JSP: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEnco ...

  7. Windows服务器修改网站上传文件的大小限制

    ASP程序 方法一: 修改该网站的的最大上传文件的大小限制 在Windows server上会出现上传大小受限制的问题,这是由于windows server的IIS管理器做了限制所致,IIS默认设置是 ...

  8. Spring Boot +Bootstrap 图片上传与下载,以及在bootstrap-table中的显示

    1.前台上传: <input type="file" name="file" id="file"> 2.后台的接收与处理: St ...

  9. Spring使用ajax异步上传文件

    单文件上传 <!-- 创建文件选择框 --> 文件上传 :<input type="file" id="file" name="fi ...

随机推荐

  1. vue路由vue-router的使用

    对于单页应用,官方提供了vue-router进行路由跳转的处理. 安装 基于传统,我更喜欢采用npm包的形式进行安装. npm install vue-router --save 当然,官方采用了多种 ...

  2. 023_nginx跨域问题

    什么是跨域? 使用js获取数据时,涉及到的两个url只要协议.域名.端口有任何一个不同,都被当作是不同的域,相互访问就会有跨域问题.例如客户端的域名是www.redis.com.cn,而请求的域名是w ...

  3. 将C注册到lua环境中使用

    注册到lua的方式有两种,一种是lua解释器,如果支持动态链接,使用动态链接机制,将函数接口编译成动态链接库,然后将动态链接库放到lua的C路径(LUA_CPATH)中,然后在lua文件中直接使用 r ...

  4. recv() failed (104: Connection reset by peer) while reading response header from upstream

    2017年12月1日10:18:34 情景描述: 浏览器执行了一会儿, 报500错误 运行环境:  nginx + php-fpm nginx日志:  recv() failed (104: Conn ...

  5. javascript for循环 日期 select

    2016年12月28日 20:01:54 星期三 html: <a href="aaaa">AAAA</a> <a href="bbbb&q ...

  6. 创建表空间、新增用户、给用户赋予DBA权限 、删除用户下的上有数据表

    正文原创 一:查询数据库实例有多少用户: [oracle@localhost ~]$ sqlplus / as sysdba; SQL*Plus: Release 11.2.0.3.0 Product ...

  7. Confluence 6 数据库整合的限制

    数据库整合的限制 注意: Confluence 自带的 XML 方式导出方法并不适用于备份和整合大数据集.这里有一些第三方的数据库工具你可以使用能够帮助你对大数据集进行备份和整合.如果你在选择正确工具 ...

  8. flutter No material widget found textfield widgets require a material widget ancestor

    Error states that TextField widgets require a Material widget ancestor. Simply wrapping your whole l ...

  9. vue element-UI 升级报错Cannot find module "element-ui/lib/theme-default/index.css"

    饿了么 用之前的版本 有些组件跟api 不一样了所以更新了最新的版本,发现 报一堆错误 主要错误是这个 Cannot find module "element-ui/lib/theme-de ...

  10. VMware安装windows10系统