Solve the problems that need to be paid attention to when configuring Tomcat's maxPostSize attribute

Solve the problems that need to be paid attention to when configuring Tomcat's maxPostSize attribute

need:

In the near future, we will implement the large file upload function. In addition to modifying the upload file limit size of the front-end framework upload control jQuery Uploadify and the file upload limit size in the MultipartResolver in the file upload module configured in the Spring MVC framework, we also need to modify the client_max_body_size attribute in the nginx.conf configuration file in the conf directory of the Nginx server and the connectionTimeout attribute and maxPostSize attribute in the server.xml configuration file in the conf directory of the Tomcat server. The above content is the modification I made.

question:

First, I modified the configuration of the Nginx server and Tomcat server and restarted the Nginx server. Then, I modified the page and code and redeployed and ran it. Then I uploaded a large file on the page, and problems occurred when submitting and saving. I suspected that there might be a problem with saving the large file, and I was busy checking the logs on the server. Then a colleague said that the file deletion function was invalid. Then another colleague said that the website could not be logged in. After entering the correct verification code, an error message said that the verification code login had expired... Various problems followed one after another. I looked at the server logs for a long time but did not find any problems. It was because I did not look carefully and did not locate where the problem occurred.

Troubleshooting:

I had no choice but to ask an expert for help. First, he asked me what I had modified. I said I had modified the configurations of both the Nginx server and the Tomcat server. The expert looked at the configuration files of the Nginx server on Linux and the server.xml configuration files of the Tomcat server, and then asked me what the configuration of the maxPostSize="0" attribute meant. I said that there is no limit on the body size under the HTTP POST request. If it is not set, the default value is maxPostSize="2097152", which is 2M in size, because the unit is Byte. Daniel then checked the relevant information and found out that it might be a problem caused by the Tomcat version. Different Tomcat versions may have different maxPostSize attribute settings. Knowing the problem, he started to configure it.

solve:

I searched for Tomcat maxPostSize on Baidu, and luckily the first result was about the maxPostSize settings for different versions of Tomcat.

Contents of this blog

After reading this blog, I checked the unified Tomcat version used in the project under Linux. The version used was Tomcat 7.0.70. Then after reading this article, what else can you say? Just change the attribute maxPostSize to -1, which means unlimited. Restart the Tomcat server, log in to the website again, and all the above problems will be gone.

Attached is the blog address of this blogger: https://www.jb51.net/article/190134.htm

Summary: Thinking about the problem that occurred yesterday, today is a good time to summarize it during the break, and then go to the relevant documents on the Tomcat official website to look at this problem. Nowadays, Tomcat versions are updated very quickly, and many Tomcat7 versions are no longer easy to find. We can check the latest Tomcat7 version information. After opening the Tomcat official website, check

Tomcat 7.0 under Documentation

Then look at the Configuration section under Reference

Next, check the HTTP section under Connectors. This is closely related to the structure of the server.xml configuration file in Tomcat's conf file. As long as you are familiar with the server.xml configuration, it is not a problem to find this.

Checking the relevant properties, we will see a detailed introduction to maxPostSize. This limit must be set to a negative number less than 0 to be unlimited. The default value is 2097152, which is 2M in size, in Byte.

You should know that the above introduction is only for Tomcat 7.0.86 version.

So how do we view the changes in Tomcat's historical versions? Go back to the document homepage where you first came in and click the Changelog section at the bottom.

Here are all the changes in the historical versions of Tomcat7. We found the Tomcat 7.0.63 version and can see that the first item that changed is the content about the maxPost attribute. The blogger above is really full of useful information. Although the content is small, it hits the mark.

Through the above summary, if similar problems occur in the future, the ability to troubleshoot problems should be improved. Summarize the troubleshooting steps yourself:

  • First: Check various logs on the server
  • Second: View various configuration files on the server
  • Third: Consider the differences between versions, such as the above question. The premise is that you need to know which configurations you have modified and which configurations you have added.

Summarize

This is the end of this article about solving the problems that need to be paid attention to in the configuration of Tomcat's maxPostSize attribute. For more relevant content about Tomcat's maxPostSize attribute configuration, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. 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
  • Tomcat maxPostSize setting implementation process analysis
  • Issues and precautions about setting maxPostSize for Tomcat
  • How to configure the maxPostSize value of built-in Tomcat in Spring Boot

<<:  Vue implements horizontal beveled bar chart

>>:  IDEA reports an error when connecting to MySQL! Server returns invalid timezone. Go to tab and set serverTimezone property

Recommend

Bootstrap realizes the effect of carousel

This article shares the specific code of Bootstra...

Linux tac command implementation example

1. Command Introduction The tac (reverse order of...

How to hide elements on the Web and their advantages and disadvantages

Example source code: https://codepen.io/shadeed/p...

MySql Group By implements grouping of multiple fields

In daily development tasks, we often use MYSQL...

Web page html special symbols html special characters comparison table

Special symbols Named Entities Decimal encoding S...

Learn the common methods and techniques in JS arrays and become a master

Table of contents splice() Method join() Method r...

Negative distance (empathy) - iterative process of mutual influence

Negative distance refers to empathy. Preface (rai...

Combining XML and CSS styles

student.xml <?xml version="1.0" enco...

A brief analysis of the usage of USING and HAVING in MySQL

This article uses examples to illustrate the usag...

Rules for registration form design

I finished reading "Patterns for Sign Up &...

Implementation of sharing data between Docker Volume containers

What is volume? Volume means capacity in English,...

Vue commonly used high-order functions and comprehensive examples

1. Commonly used high-order functions of arrays S...

JavaScript offsetParent case study

1. Definition of offsetParent: offsetParent is th...