Reputation: 9958
I am using GlassFish 4, and my JSP file is simple:
<%@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>
This is my request GET index.jsp?a=历史
, and the output is:
åå²
What's wrong with it?
Upvotes: 0
Views: 4292
Reputation: 94
You can use this code "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>
Upvotes: 5