본문 바로가기

프로그래밍/JSP _ Servlet _ Beans

JSP 한글 깨짐 현상..

페이지 상단에 페이지 선언을 해줍니다.

[code type=html4strict]<%@ page contentType = "text/html; charset=euc-kr" %>
[/code]

이렇게 해주면 일단 왠만한 걱정은 싸 잡으셔도 될겁니다. 두번째 방법은 문자열(String)을 직접 코드 변환해주는 방법입니다. 함수로 만들어 사용해도 좋습니다.

[code type=html4strict]
out.println(new String(("자바속의 한글").getBytes("8859_1"), "EUC-KR"));
<%!
//한글 처리
public String ko(String str) {

try{
str = new String(str.getBytes("8859_1"), "EUC-KR");
} catch(UnsupportedEncodingException e) {
}
return str;
}
%>

<%
out.println(ko("자바속의 한글"));
%>[/code]



from
http://okjsp.pe.kr