티스토리 뷰

자바(Java)

ajax 전송 최대 크기 톰캣

xemaker 2020. 3. 20. 14:45

ajax로 파라미터 전송하고 자바 컨트롤러에서 찍어봤는데

null로 찍히는 것이였다.

이상하다..

데이터가 작은것은 잘 넘어가는데..

뭔가 설정 문제임을 직감하고 구글링을 해본결과

톰캣 server.xml 의

<Connector 에다가 maxPostSize="-1" 을 추가해주니 되었다.

 

 

1. 설정

2-1. 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.

2-2. 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.


2. 주의사항

server.xml 설정 파일에 아래와 같은 파라미터가 설정되어 있고 특히 0으로 되어 있지 않은지 본다.

 

0 설정 관련하여 정확히는 Tomcat 7.0.63 기준으로 다르다.

 

  • Tomcat 7.0.63 미만 : maxPostSize를 0으로 설정하면 무제한
  • Tomcat 7.0.63 이후 & Tomcat 8.x 이후 : maxPostSize를 -1로 설정해야 무제한

3. 예제

  • 만약 maxPostSize="8"로 잡았다고 하자.
  • key=abcde 라는 POST 데이터를 넘긴다고 하면 넘어가지 않는다.
  • key=abcd 는 넘어간다. 8바이트이기 때문이다.

<Connector port="8180" protocol="org.apache.coyote.http11.Http11NioProtocol" maxPostSize="8" maxThreads="1024" URIEncoding="UTF-8" acceptCount="10" enableLookups="false" compression="false" connectionTimeout="20000" redirectPort="8543" />

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함