Struts2 file upload exceeds size limit unable to jump to the specified input page problem, browser prompts the connection has been reset? Root cause

Source: Internet
Author: User
Tags tomcat server

Struts2 file upload exceeds size limit unable to jump to the specified input page issue. The browser prompts the connection to reset the problem:




root Cause:

This problem appears with the TOMCAT7/8/9 version. The root cause is TOMCAT7/8/9 and struts2 compatibility issues : When the maximum number of bytes in request (excluding transmission encoding overhead) exceeds the Tomcat server conf file Server.xml
The set value of the maxswallowsize will be uploaded by Tomcat, and Tomcat will determine that it was a failed upload,
This request will not be transferred to the application Servlet object, so no application servlet will respond to this request.
But the client does not receive a response that exceeds the upload limit, so the client will still send it. So Tomcat will send a

The connection is reset to the client (browser).

this will cause the file upload to exceed the size limit can not jump to the specified input page, the browser prompts the connection has been reset problems.

************************************************************

reply message:

chuan_jing 2017-07-14 04:381 floor
Thank you, you can solve it in your way. But I do not understand: When I do not configure maxswallowsize="-1", use native commons-fileupload to upload large files, or use servlet3.0 upload large files, browsers are not prompted to connect has been reset, can upload success, but the use of struts2 upload large files will be Tomcat interception, according to this phenomenon, should not be Tomcat configuration problem ah, can you help me explain it.
zyw23zyw23 2017-07-14 10:162 Floor According to your debugging results, it should not be Tomcat configuration problem, but Struts2 problem.
You can do breakpoint debugging in the three ways you say, focusing on the third scenario when the user uploads the single instance servlet, the Struts2 filter filters the Dofilter () statement before the call, and if you're talking about the problem, it probably should be there.
1, users upload------tomcat (generate single-instance servlet3.0)------write their own upload functions.
2, the user uploads------tomcat (Generate single instance servlet)------commons-fileupload.
3, the user uploads------tomcat (generate single-instance servlet)------struts2------commons-fileupload.
zyw23zyw23 just replied chuan_jing: Today when I encountered a 405 error in SRINGMVC forwarding to the JSP: JSPs only the question of the only permit getting POST or head, suddenly thought Your question, in fact, is not a tomcat problem, it's not a struts2 problem, but a compatibility issue with TOMCAT7/8/9 and struts2 (I guess: because of the change of Tomcat version, added new features, new security features, In the flow of data that Tomcat provides to struts2, some information about the previous version of Tomcat is changed, but the struts2 does not adjust accordingly to these changes, which has a compatibility problem, so this occurs.

*************************************************************


Workaround: Modify Maxswallowsize to-1, note:-1 is not necessarily suitable for practical applications,


Detailed information can go to Tomcat official website to view the documentation, the following is the configuration information detailed introduction page: https://tomcat.apache.org/tomcat-9.0-doc/config/http.html
Set value for Maxpostsize and Maxswallowsize in the Tomcat server conf file Server.xml: If you do not specify a default value for the default 2097152 (2MB), less than 0 indicates no limit.

Example:

<connector connectiontimeout= "20000" port= "8080" protocol= "http/1.1" redirectport= "8443" maxSwallowSize= "-1"/ >

This will normally jump to the input error page that you have defined well.


The maxswallowsize value in the actual application is set according to the business requirements, because the REQUEST,TOMCAT server that exceeds the Maxswallowsize value does not pass to the application Servlet object, so there are two ways to fix it:

1. Through the Tomcat server level Setup solution, this problem is beyond my ability range.

2. In addition, you can upload the file on the front page to do beyond the file upload limit to determine the value of a hint, with the appropriate set of maxswallowsize values used.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.