Issues and precautions about setting maxPostSize for Tomcat

Issues and precautions about setting maxPostSize for Tomcat

1. Why set maxPostSize?

The tomcat container has a limit on the size of the transmitted data. If a file exceeding this value is uploaded, an error will be reported, making the program unable to be used normally.

2. Setting method

Find /conf/server.xml in the tomcat directory and add the maxPostSize parameter to it

The parameter value "-1" means no size limit. Not setting the maxPostSize parameter means using the default size, which is 2097152 bytes, or 2 megabytes.

3. Notes on setting values

One thing to note is that when there is no limit on the size of transmitted data under different versions of Tomcat, the value of maxPostSize is not the same!

Specific differences:

Before tomcat7.0.63, setting maxPostSize to a value less than or equal to 0 means no limit

In tomcat7.0.63 and later, setting maxPostSize to a value less than 0 indicates no limit

If you set maxPostSize="0" after tomcat7.0.63, the transmitted data will not be obtained.

4. Official Documentation

Attach tomcat changeLog

ps: Tomcat sets maxPostSize, causing Post request to fail

question:

I recently deployed a project using Tomcat version 7.0.82.0. I found that I couldn't log in. I found that the data from the front end could not be passed to the back end.

Troubleshooting: Through the debug log, it was found that the backend did not receive the login data of the front-end user. After checking, it was found that Tomcat added the parameter maxPostSize=0 in server.xml. After deleting this parameter, it was found that the data was received.

analyze:

I searched for maxPostSize=0, which means that the post request has no size limit. After googling for a long time, I found that the meaning of the parameter maxPostSize has changed since apache-tomcat-7.0.63: If the value is set to 0, it means that the maximum POST value is 0. To have no limit on the POST size, you need to set the value to -1. , before this version, set to 0 to indicate no limit on the POST size.

This is the end of this article about the problems and precautions of setting maxPostSize for Tomcat. For more information about setting maxPostSize for Tomcat, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solve the post parameter restriction problem by setting tomcat through spring boot
  • Solve the problems that need to be paid attention to when configuring Tomcat's maxPostSize attribute
  • Tomcat maxPostSize setting implementation process analysis
  • How to configure the maxPostSize value of built-in Tomcat in Spring Boot

<<:  Vue+echarts realizes stacked bar chart

>>:  Detailed tutorial on installing mysql 8.0.20 on CentOS7.8

Recommend

How to make CSS child elements highly consistent with parent elements

Absolute positioning method: (1) Set the parent e...

How to use Antd's Form component in React to implement form functions

1. Construction components 1. A form must contain...

CSS3 realizes the red envelope shaking effect

There is a requirement to realize the shaking eff...

Provides helpful suggestions for improving website design

<br />Scientifically Design Your Website: 23...

What is BFC? How to clear floats using CSS pseudo elements

BFC Concept: The block formatting context is an i...

Server concurrency estimation formula and calculation method

Recently, I need to stress test the server again....

Linux installation MySQL tutorial (binary distribution)

This tutorial shares the detailed steps of instal...

Implementation of Docker batch container orchestration

Introduction Dockerfile build run is a manual ope...

Centos7 startup process and Nginx startup configuration in Systemd

Centos7 startup process: 1.post(Power-On-Self-Tes...

How to create a stylish web page design (graphic tutorial)

"Grand" are probably the two words that ...

How to develop uniapp using vscode

Because I have always used vscode to develop fron...

A detailed introduction to for/of, for/in in JavaScript

Table of contents In JavaScript , there are sever...