코딩항해기

[Error/Tomcat] 400 IllegalArgumentException (유효하지않은 문자) 본문

Error solution

[Error/Tomcat] 400 IllegalArgumentException (유효하지않은 문자)

miniBcake 2024. 10. 14. 12:50

 

java.lang.IllegalArgumentException: 요청 타겟에서 유효하지 않은 문자가 발견되었습니다.

 

ajax를 사용해 JSON파일을 GET방식으로 비동기처리하려고 했더니 해당 오류가 발생했다.

해당 오류를 해결하는 방법으로 크롬 브라우저 사용하기, 서버파일에 설정 추가하기, encodeURIComponent랑 encodeURI 사용하기 등이 있었지만 해당 방법으로 해결되지 않았다. JSON파일로 통신할 때는 GET방식을 사용할 수 없고 POST방식으로 통신해야한다.

 

POST방식으로 진행하면 정상적으로 진행되는 것을 확인할 수 있다.

 

encodeURI 관련 MDN글

 

encodeURI() - JavaScript | MDN

The encodeURI() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two surroga

developer.mozilla.org

 

encodeURI와 encodeURIComponet 차이

 

encodeURIComponent()와 encodeURI()의 차이

https://www.freecodecamp.org/news/javascript-url-encode-example-how-to-use-encodeuricomponent-and-encodeuri/해당 글에 대한 번역입니다.URL에는 아스키 코드로 정의된 128개

velog.io