The first type:in front of the page, add
<%@ page language= "java" contenttype= "TEXT/HTML;CHARSET=GBK"
errorpage= ""%>
<%request.setcharacterencoding ("GBK");%>
The first line indicates that your page is in Chinese code
the second line declares that your page values are also encoded in Chinese
The second kind
tomcat4.x support in the messaging code, but 5.x does not support, if you use more than 5.0 of the version will have to Transcode,
That 's the format .
string Strkeywords=new string (Request.getparameter ("Key_words"). GetBytes ("Iso8859_1"), "gb2312"); This is our project to solve the SQL Server Chinese garbled scheme, you can try
JSP page saved to database garbled solution
Jsp+tomcat+bean Chinese garbled problem solving method JavaBean parameter is garbled
1) All JSP pages specify character encoding methods, such as: Charest=gb2312,charest=utf-8, etc.
2) Locate the line that sets the server port in the Server.xml party in the application server, usually beginning with this: "<connector port=" 8080 "",
3) Add: uriencoding= "UTF-8" after the string that begins with the found line "<connector", save the file
--------------------------------------------------------------------------
JSP page has garbled resolution method
all JSP pages specify character encoding, such as: Charest=gb2312,charest=utf-8, etc.
<%@ page contenttype= "text/html; charset=utf-8" >
--------------------------------------------------------------------------
JSP single Chinese parameter garbled solution method
Use this to convert:
<%! String trans (string chi)
{
string result =null;
byte temp[];
temp=chi.getbytes ("iso=8859-1");
result= New String (temp);
}
%>
or just like this:
<%
request.setcharacterencoding ("UTF-8");
out.println (request.getparameter ("parameter id")
%>
--------------------------------------------------------------------------