보내려는 배열은
var tempArray = new Array();
tempArray.push('a_data');
tempArray.push('b_data');
에이작스는
$.ajax({
type: ...
dataType: ...
url: ...
contentType: ...
data: {
'어쩌고': 저쩌고,
~~~~
'tempArray':tempArray
},
success ......
});
이런식으로 넘겨버리면
콘솔에서는
심각: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NumberFormatException: For input string: ""] with root cause
java.lang.NumberFormatException: For input string: ""
웹에서는
블라 블라 ~~ &tempArray%5B%5D=aaa&tempArray%5B%5D=bbb 500 (Internal Server Error)
난리 부르스를 쳐댄다.
자세히 보면 원래 보내고자하는 tempArray=aaa 가 tempArray%5B%5D=aaa 와 같이 인코딩이 깨진 것을 확인 할 수 있다.
[해결방법] ajax 호출 전
$.ajaxSettings.traditional = true;
코드를 넣어주고 실행해보면 인코딩이 정상적으로 넘어가는 것을 확인 할 수 있다.
[출처 및 이유 확인] http://marobiana.tistory.com/108 by 신매력
'jQuery' 카테고리의 다른 글
radio box(라디오 박스)값 변경 시 이벤트 (0) | 2017.01.10 |
---|---|
select 박스에 생성된 값을 가져와서 출력하기 (0) | 2016.09.27 |
GET 방식 ? POST 방식 ? GET 방식 제한은 2048글자? (0) | 2016.08.23 |
배열 eq(index) 접근 방법 (0) | 2016.08.01 |
jQuery css 다중 값 적용 (0) | 2016.07.28 |