Eclipse compiler encoding and JSP Java and other file encoding.

Source: Internet
Author: User

First, set the default encoding of JSP java files in eclipse


Window-preference Example 1:


In this case, all JSP Java will follow the default encoding.


Troubleshooting:

1. If a JSP is garbled in eclipse, it must be because someone has changed the default code of JSP in eclipse,

View the JSP property, as shown in Figure 2:



If we see that the JSP code is GBK, if the JSP code is garbled, the default encoding of JSP is definitely not GBK,


2. If garbled characters appear on the client page, check whether the servlet temporary file generated by JSP is entered correctly. The location of the response is based on the Tomcat JBoss and other response positions of different servers,

Check whether JSP-servlet is correct. 3:



If the file is generated incorrectly, check whether the file's encoding is configured or whether the global JSP encoding code is configured in Web. xml.

For example:

<JSP-config>
<JSP-property-group>
<Description>
Special Property Group for JSP configuration JSP
Example.
</Description>
<Display-Name> jspconfiguration </display-Name>
<URL-pattern> *. jsp </url-pattern>
<El-ignored> true </El-ignored>
<Page-encoding> GBK </page-encoding>
<Scripting-invalid> false </Scripting-invalid>
<Include-prelude> </include-prelude>
<Include-coda> </include-coda>
</JSP-property-group>
</JSP-config>



3. Test the modification. If you modify the default eclipse encoding, the source file becomes garbled.

If you modify the file attributes, the file becomes garbled.


4. encoding conversion: in windows, the source file is first copied to the memory. At this time, the charseta file is first converted

Unicode encoding, and then convert to the new encoding charsetb. This operation is not necessarily reversible. For example, charseta has an uncode Code, for example

GBK-> Unicode 0x80, 0x80 Unicode without this encoding will make/ufffff, that is? At this time, convert it to charsetb.

You will know what the original content is.


5. The file attribute is different from the built-in pageencoding. This is very serious, and 2nd cases will occur, because during the JVM compilation process, it is based on

Pageencoding is used to Parse Files. For example, if a GBK-encoded file requires pageencoding to be written as UTF-8, it will first convert the file to Unicode.

0 x, 0x87. For example, if this parameter represents "high" in the Chinese GBK, the JVM will be parsed to Unicode according to the UTF-8 standard.

Character, it may make other characters "begin", or "yellow"

Therefore, an error occurred while compiling the servlet.


6. Why should I copy the garbled content of the file and copy it back to the eclipse file in a text editor such as ultraediter?

Because the garbled characters are already unicode encoded when they are copied to the memory, they are modified to a correct Chinese encoding GBK gb2312 by ultralediter, etc.

It doesn't matter, and then copy the uncode code of the correct content, and then copy it back to the eclipse JSP file and convert it into the correct characters, which is correct.

 

 

7. the encoding of the returned page is incorrect. The JSP charset is set to GBK, but the setencodingfilter is used as a whole.

When the request is accepted, all requests are converted to UTF-8, so that the data will become garbled during the action Acceptance, because IE will follow

The server charset encoding encodes the submitted data, and the server uses setencodingfilter to encode the encoding information.

Set once, so if charset and setencodingfilter are different in encoding, there will be situations like 4.

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.