<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="java.io.*"%>
<%
! String trans(String chi) {
String result = null;
byte temp[];
try {
temp=chi.getBytes("iso-8859-1");
result = new String(temp);
} catch(UnsupportedEncodingException e) {
System.out.println(e.toString());
}
return result;
}
%>
<%
out.println(trans(request.getParameter("name")));
%>
另外还有一种很简单的方法
request.setCharacterEncoding("gb2312");