springboot设置tomcat post参数大小限制修改方式
SpringBoot项目上使用富文本框,如果图片很多的话,会报如下错误:
2020-09-28 14:26:59.568 ERROR 8 --- [nio-8098-exec-5] Servlet.service() for servlet [dispatcherServlet] in context with path [/product-manage] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector] with root cause
java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector
这个是字符串接收,不是文件接收,请求方式是post,post本身没有参数大小限制,但是tomcat给限制了,于是解决方式如下:
一、外置的tomcat
这个简单,直接在server.xml里面添加或者修改这句话:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="2000" redirectPort="8443" URIEncoding="UTF-8" maxThreads="3000" compression="on" compressableMimeType="text/html,text/xml" maxPostSize="0" />
修改这里的maxPostSize的值,默认是1024,改成0,就可以不限制了大小了
二、使用spring boot自带的tomcat
那就在application.properties中加上这句话:
server.tomcat.max-http-post-size=0
如果是SpringBoot 2.x版本加这句话:
server.tomcat.max-http-post-size=-1
修改了配置之后记得重启服务器,做了热部署的伙伴,如果无效,记得重启一下再测试。
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
Java创建型设计模式之抽象工厂模式(Abstract Factory)
当系统所提供的工厂所需生产的具体产品并不是一个简单的对象,而是多个位于不同产品等级结构中属于不同类型的具体产品时需要使用抽象工厂模式,抽象工厂模式是所有形式的工厂模式中最为抽象和最具一般性的一种形态2022-09-09
@RunWith(SpringJUnit4ClassRunner.class)报错问题及解决
这篇文章主要介绍了@RunWith(SpringJUnit4ClassRunner.class)报错问题及解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-04-04
java中线程的sleep()方法和yield()方法的区别
本文主要介绍了java中线程的sleep()方法和yield()方法的区别,Thread类的sleep()方法使线程休眠指定时间,不释放锁,而yield()提示调度器当前线程愿意让出CPU资源,不保证立即切换线程,感兴趣的可以了解一下2024-10-10
SpringBoot2.1.3修改tomcat参数支持请求特殊符号问题
最近遇到一个问题,比如GET请求中,key,value中带有特殊符号,请求会报错。接下来通过本文给大家分享解决SpringBoot2.1.3修改tomcat参数支持请求特殊符号 ,需要的朋友可以参考下2019-05-05


最新评论