Change encoding and solve some garbled problems in eclipse

Source: Internet
Author: User
Tags character set http request

1. Change the encoding of the entire working space:

Click Window->preference->general->workplace, and then select the default encoding method.

2. Change the encoding method of an item:

Right-click on the project name->properties>resource and select Default encoding method.

question: If you right click on the project name->preferences->resource, change the code to UTF-8, then the item will appear in Chinese garbled.

so the project is preferences and cannot be changed to Utf-8, so it defaults to GBK encoding. You know why.

Answer: The reason is that when we build the project in Eclipse, the default encoding for Eclipse is GBK, and if you change its encoding to UTF-8, the project will be garbled in Chinese. There is also the case that the project from Myeciipse into eclipse will also appear in Chinese garbled, the same reason, this is because the default encoding of MyEclipse is utf-8, if you directly import the default code for the GBK eclipse, of course, there will be problems. Therefore, if you want to not appear in Chinese garbled, the code of the project must be consistent. If we want to import utf-8 encoded projects in Eclipse, we first have to change the default encoding for Eclipse by clicking Windows->preference->workplace and choosing the default encoding of Utf-8.

3. Change the encoding method of a file:

Right-click the file name->properties>resource, and then select the default encoding method.

4, change the encoding of all files of the same file type:

1) Open eclipse to find window->preferences->general->content Types;
2) Find the type of file to be modified (java,jsp, etc.), there is a default encoding below, enter GBK or other encoding method in the input box;
3) Click Update;
4) Click OK;
5) restart eclipse;

5. Eclipse Settings new JSP file default character encoding is Utf-8

Window>preference->web-> JSP Files finds the encoding and then changes to Utf-8.

6, HTTP request response, coding considerations.

When doing a Web project, there are several coding methods that need to be noted: the coding of the project, the encoding of the request response, the encoding of the Get mode parameters, the encoding of the browser (or the more accurate encoding of the Web page), and the encoding of the server. In short encoding and decoding way has been, will not appear in Chinese garbled. These have yet to be summed up in practice ...

2) The general request encoding to set the same as the browser encoding, or it will appear garbled.

3) When the Get form is submitted in accordance with the UTF-8 character set for URI encoding, the input may be Chinese variables first set Urlencoder re-pass value. such as: name = Urlencoder.encode (name, "Utf-8");

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.