티스토리 뷰
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
김보야 2019. 5. 21. 14:30
클라이언트에서 파라미터 값을 URLEncode하여 보내준다면 가장 좋겠지만,
클라이언트를 수정할 수 없는 경우에는 서버쪽에서 수정해야합니다.
톰캣 7 특정버전 이상부터 파라미터 값에 특수문자를 받을 수 없도록 수정되었고,
권장하진 않지만 필요하다면 relaxedQueryChars 옵션을 주어 받을 수 있도록 설정 할 수 있습니다.
이런 옵션을 사용하고 싶진 않을 경우엔 하위 버전으로 다운그레이드를 하면 됩니다.
relaxedQueryChars |
The HTTP/1.1 specification requires that certain characters are %nn encoded when used in URI query strings. Unfortunately, many user agents including all the major browsers are not compliant with this specification and use these characters in unencoded form. To prevent Tomcat rejecting such requests, this attribute may be used to specify the additional characters to allow. If not specified, no additional characters will be allowed. The value may be any combination of the following characters: " < > [ \ ] ^ ` { | } . Any other characters present in the value will be ignored. |
relaxedQueryChars에 허용하고자 하는 특수문자 입력
설정 예시>
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"
relaxedQueryChars="^{}[]|"<>" />