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

Implementation of Docker data volume operations

Getting Started with Data Volumes In the previous...

Analysis of the principle and usage of MySQL custom functions

This article uses examples to illustrate the prin...

A detailed discussion on detail analysis in web design

In design work, I often hear designers participati...

Vue image cropping component example code

Example: tip: This component is based on vue-crop...

A brief discussion on the implementation principle of Webpack4 plugins

Table of contents Preface know Practice makes per...

Specific use of the wx.getUserProfile interface in the applet

Recently, WeChat Mini Program has proposed adjust...

In-depth understanding of uid and gid in docker containers

By default, processes in the container run with r...

Use HTML and CSS to create your own warm man "Dabai"

The final result is like this, isn’t it cute… PS:...

Summary of commonly used tool functions in Vue projects

Table of contents Preface 1. Custom focus command...

How to use Docker to build OpenLDAP+phpLDAPadmin unified user authentication

1. Background Use LDAP to centrally manage operat...

Docker deploys Macvlan to achieve cross-host network communication

Basic concepts: Macvlan working principle: Macvla...

How to view the IP address of Linux in VMware virtual machine

1. First, double-click the vmware icon on the com...