2013-08-09 3 views
0

나는 글래스 피쉬 4를 사용하고, 내 JSP 파일은 간단하다 :JSP에서 utf8 인코딩을 사용하여 GET 매개 변수를 얻으려면 어떻게해야합니까?

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <%= request.getParameter("a") %> 
    </body> 
</html> 

이 내 요청 GET index.jsp?a=历史이며, 출력은 : 그것은 잘못 무엇

åå² 

?

+1

<% = request.getParameter ("A"). getBytes ("ISO-8859-1"), "UTF-8") %>이 시도 – Satya

+0

반 친구들 중 하나는, 그것을 발견했지만입니다 utf8로 URL의 기본 인코딩을 변경하는 더 convient 방법이 있습니까? –

+0

이 URL 확인 http://stackoverflow.com/questions/1365806/why-the-character-is-corrupted-when-use-request-getparameter-in-java – Satya

답변

5

"a_receive = new String (a_receive.getBytes ("ISO8859_1 "),"UTF-8 ");"이 코드를 사용할 수 있습니다.

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <% a_receive = request.getParameter("a") 
      a_receive = new String(a_receive.getBytes("ISO8859_1"), "UTF-8"); 
%> 
     <%=a_receive %> 
    </body> 
</html> 
관련 문제