JSP page saved to database garbled solution

Source: Internet
Author: User
Tags server port

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")
%>
--------------------------------------------------------------------------
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.