반응형

보내려는 배열은

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 신매력

반응형

+ Recent posts