728x90

특정 경로(URL)를 특수 기호문제로 encoding 해야되는 경우 URLencode.escape("url 경로") 를 사용한다

 

=============================================== Example ===========================================

Ex)

String url = ""; //변환된 url를 담을 변수

String tempUrl = "/test/fold/test.jsp"; //변경할 url

link = URLencode.escape(tempUrl); //url encoding

= %2Ftest%2Ffold%2Ftest.jsp"// 슬러시(/) 기호가 %2F 로 치환된 것을 확인, &기도 등도 치환된다.

특정 값(value)를 UTF-8 or EUC-KR encoding 해야되는 경우 java.net.URLEncoder.encode("value", "type")를 사용

 

=============================================== Example ===========================================

Ex)

String encodeVal = java.net.URLEncoder.encode("가나다라", "UTF-8");

=> "가나다라" 를 UTF-8 로 인코딩(encoding)
String decodeVal = java.net.URLEncoder.encode(encodeVal, "EUC-KR");

=> UTF-8 로 인코딩 된 "가나다라" 를 EUC-KR 로 재 인코딩(encoding) => "가나다라" 가 원상복귀됨

 

728x90

'프로그래밍 > java' 카테고리의 다른 글

Java 정규식  (0) 2015.07.24
오픈소스 링크  (0) 2015.06.26
전자정부(Spring) Framework] iBatis 입력(INSERT) 결과  (1) 2015.05.19
java jdbc db instance 설정  (0) 2015.05.06
오라클 페이징  (0) 2014.07.23

+ Recent posts