Solution to saving the jsp page to the database with garbled characters
First: add
<% @ Page language = "java" contentType = "text/html; charset = gbk"
ErrorPage = "" %>
<% Request. setCharacterEncoding ("GBK"); %>
The first line indicates that your page uses Chinese encoding.
The second line declares that your page value is also encoded in Chinese.
Second
Tomcat4.x supports Chinese Character transfer, but 5.x does not. If you use a version later than 5.0, you have to transcode it,
This is the format
String strKeyWords = new String (request. getParameter ("key_words "). getBytes ("iso8859_1"), "gb2312"); this is a solution for our project to solve Chinese garbled characters.
Solution to saving the jsp page to the database with garbled characters
Jsp + tomcat + bean Chinese garbled problem solution an contains garbled Parameters
1) All jsp pages specify the character encoding method, such as: Charest = gb2312, Charest = UTF-8, etc.
2) Find the line for setting the server port in the server. xml component of the application server, which generally starts with this :" 3) Find the row" --------------------------------------------------------------------------
Jsp page garbled code Solution
All jsp pages specify character encoding methods, such as: Charest = gb2312, Charest = UTF-8, etc.
<% @ Page contentType = "text/html; charset = UTF-8">
--------------------------------------------------------------------------
Solution to garbled characters of a single Chinese parameter in jsp
Use this to convert:
<%! String trans (String chi)
{
String result = null;
Byte temp [];
Temp = chi. getBytes ("iso= 8859-1 ");
Result = new String (temp );
}
%>
Or directly:
<%
Request. setCharacterEncoding ("UTF-8 ");
Out. println (request. getParameter ("parameter ID ")
%>
--------------------------------------------------------------------------