본문 바로가기
Tools/Eclipse & STS

[SPRING] Tomcat(톰캣) post로 넘기는 파라미터 최대 개수와 size 설정하기 (feat. maxParameterCount / maxPostSize)

by 썸머워즈 2019. 11. 13.
반응형

- post로 넘기는 파리미터 최대 개수와 크기 설정 -


웹 앱 연동을 진행하던 도중 

 

Map을 이용한 파라미터를 옮기는데 VO의 항목들만 보내면 보내지는데 

 

특히 사진을 여러장 첨부해서 보내면 아무값도 안보내지는 이상한 현상을 겪었다.

(너무 갑자기 파라미터가 안넘어간다...)

 

이것저것 알아본 결과 

최대 Size 를 초과했기에 일어난 현상이었다.

해결해가며 알아간 내용을 기록해두고자 한다.

 


Tomcat은 기본적으로 Post로 넘길 수 있는 파라미터의

 

최대 크기(Size) 는 2097152 (2 megabytes) 이며

최대 개수는 10000개라고 한다.

 

(8.0을 기본적으로 사용하기에 8.0기준으로 적어본다.)

 

maxParameterCount

The maximum number of parameter and value pairs (GET plus POST) which will be automatically parsed by the container. Parameter and value pairs beyond this limit will be ignored. A value of less than 0 means no limit. If not specified, a default of 10000 is used. Note that FailedRequestFilter filter can be used to reject requests that hit the limit.

maxPostSize

The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than zero. If not specified, this attribute is set to 2097152 (2 megabytes). Note that the FailedRequestFilter can be used to reject requests that exceed this limit.

 

위에 표를 보면 실제로 Tomcat 공식홈페이지에 나와있는 설정값들이다.

(출처 : http://tomcat.apache.org/tomcat-8.0-doc/config/http.html)

본인의 Tomcat 버전에 맞게 확인하면 좋을거 같다.

 

여기서 나와있는거 처럼 최대 크기와 개수를 조절해주기 위해서는

maxParameterCount maxPostSize 추가로 설정해 주어야한다.

 

Servers > server.xml 에 들어가보면

 

자주 등장하는 다음과같이 포트를 지정하거나 하는 부분이 있는데

 

거기에 각각 "-1" 을 선언해 주어 무제한으로 설정해주면 된다.

(필요에 따라서 직접 크기를 70000 이런식으로 설정해 주어도 된다.) 

 

<Connector connectionTimeout="20000" port="8081" protocol="HTTP/1.1" redirectPort="8443" maxPostSize="-1" maxParameterCount="-1"/>

 

여기서 주의할 점이 있는데

 

Tomcat7의 특정 버전 이하의 경우에는 무제한 설정이 0또는 그 이하라 되어있어

Tomcat6 버전을 사용했을 경우에도 0으로 설정해도 상관없지만

Tomcat7 이상에서는 -1로 설정해주어야 무제한 설정이라고 한다.

반응형


댓글

TOP