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

Detailed explanation of virtual DOM and diff algorithm in react

The role of virtual DOM First of all, we need to ...

Summary of various methods of MySQL data recovery

Table of contents 1. Introduction 2. Direct recov...

MySQL index leftmost principle example code

Preface I was recently reading about MySQL indexe...

Detailed explanation of flex layout in CSS

Flex layout is also called elastic layout. Any co...

Docker image creation Dockerfile and commit operations

Build the image There are two main ways to build ...

Windows DNS server exposed "worm-level" vulnerability, has existed for 17 years

Vulnerability Introduction The SigRed vulnerabili...

A simple way to achieve scrolling effect with HTML tag marquee (must read)

The automatic scrolling effect of the page can be...

Detailed explanation of nmcli usage in CentOS8

Common nmcli commands based on RHEL8/CentOS8 # Vi...

Detailed explanation of the use of Vue.js draggable text box component

Table of contents Registering Components Adding C...

Detailed tutorial of pycharm and ssh remote access server docker

Background: Some experiments need to be completed...