페이지

2014년 3월 19일 수요일

devon 에서 ajax전송시 한글깨 때

데브온에서 ajax로 데이터 전송할때 기본적으로 utf-8로 세팅되어 있는거 같습니다

그래서 한글 보낼때 깨지는 문제가 있는데 이럴땐 2가지 방식이 있고

1. web.xml에서 ajax파일은 utf-8로 보내기

2. xsync.js에서 addquery()부분에서 값 감싸는 부분을 escape(encodeURIComponent(value)) 이런식으로 감싸서 보낸 후
   받는쪽에서 new String(URLDecoder.decode(cpName,"UTF-8")) 이렇게 받으면 됩니다





web.xml sample

 
<filter>
    <filter-name>CharsetEncodingFilter-utf-8</filter-name>
    <filter-class>util.CharsetEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>
 
 
 
<filter-mapping>
        <filter-name>CharsetEncodingFilter-utf-8</filter-name>
        <url-pattern>*.devx</url-pattern>
</filter-mapping>

댓글 없음:

댓글 쓰기

image

image