0

我正在使用GlassFish 4,我的 JSP 文件很简单:

<%@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=历史,输出是:

åå² 

它出什么问题了?

4

1 回答 1

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>
于 2014-01-08T08:39:37.103 回答