The problem of file.encoding when Tomcat starts

Source: Internet
Author: User
Linux system default encoding Utf-8
To modify and view the Linux coding problem:
[HTML]View plain copy [root@test-1 ~]# vi/etc/sysconfig/i18n lang= "en_US. UTF-8 "sysfont=" Latarcyrheb-sun16 "

Linux default encoding UFT-8, the terminal output default encoding is naturally UTF-8.

Windows using the SECURECRT default encoding is GBK, link to the Linux system output garbled, because Linux default is Utf-8, so the securecrt of the default encoding to Utf-8 on OK.


WINDOWS default Encoding GBK
Understanding the system platform's coding is easy to solve the coding problem.
The default encoding for Tomcat-initiated consoles in WIN7 is GBK, which is generally default to the system default character set.
The commonly used international encoding of Tomcat is Utf-8, and the application output adopts the system default encoding GBK,

So garbled, and then start the JVM set to-dfile.encoding= "UTF-8", the use of garbled problems to solve.


Here's another question:

Java.NET.URLEncoder.encode ("China"); If the encoding system is not added, the system is encoded by default. System.getproperty ("file.encoding");

If you jetty, Tomcat does not have the-dfile.encoding= "UTF-8" when it is started, the encoding problem occurs when the encryption is decrypted.

Solution:

The reason is because the default character set of the file.encoding is related to the operating system, the default character set below the Chinese operating system is GBK, if the process-defined XML file uses UTF-8,

is not converted correctly, you need to modify the value of file.encoding to UTF-8.

Files deployed in Tomcat to modify the value of file.encoding can be added after the set java_opts=%java_opts%%logging_config% in Tomcat's Catalina.bat file- Dfile.encoding= "UTF-8"

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.