spring boot sets tomcat post parameter limit

I used base64 string and POST method to upload pictures today. The front-end always crashed inexplicably. I searched the Internet for a long time, thinking that the file size was limited, but I was receiving strings, not files, so Continue to search again, it turns out that the post itself has no parameter size limit, but tomcat limits it, so the solution is as follows:

1. External tomcat

This is simple, add or modify this sentence directly in 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 "
/>

Yes, it is to modify the value of maxPostSize here. The default is 1024. If you change it to 0, you can not limit the size.

 

2. Use the tomcat that comes with spring boot, then add this sentence to application.properties:

server.tomcat.max-http-post-size=0

I searched a lot on the Internet before, and the most popular one is: spring.http.multipart.file-size, but this is not to set the file size, but to set the post parameter string size, and some methods have been deprecated.

important! ! ! , after modifying the configuration, the partners who did not do hot deployment remember to restart the server, and the partners who did hot deployment, if it does not work, remember to restart and test again.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325971339&siteId=291194637