springboot设置tomcat post参数大小限制修改方式
目录
- 一、外置的tomcat
- 二、使用spring boot自带的tomcat
- 总结
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.springframewyhhDaCIaxqork.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is Java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploade编程客栈d 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 portpython="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
修改了配置之后记得重启服务器,做了热部署的伙伴,如果无效,记得重启一下再测试。
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程客栈(www.devze.com)。
加载中,请稍侯......
精彩评论