Javaweb Submit Chinese data garbled problem summary __ Big Data

Source: Internet
Author: User
Using Post submission

If the submission is post, think not garbled, just need to set up the request object in the server code can be, the client in which encoding to submit, server-side Request object to the corresponding code to receive, such as the client is submitted in UTF-8 code, The server-side Request object is received in UTF-8 encoding (request.setcharacterencoding ("UTF-8")) using get commit

If the Submit method is get, the encoding for the request object is invalid, and the request object receives the data with the default iso8859-1 encoding, so you can only convert the data manually after you receive it, as follows:

Gets the data that the client submits, gets the garbled string, data= "??? È????? "

 

Look up the Iso8859-1 code table and get the byte array of the raw data submitted by the client

 

Constructs a string from a byte array to the specified encoding, resolving garbled

 

Constructs a string with the specified encoding in a byte array, where the specified encoding is based on the character encoding used by the client to submit the data, if it is GB2312, then set to data = new string (source, "GB2312"), if it is UTF-8, Then set to data = new String (source, "UTF-8")

Reference articles:

Http://www.cnblogs.com/xdp-gacl/p/3798347.html

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.