Issue background:
In the myeclipse development of the Tomcat version of the Web program, the program through the network request, from the remote server to obtain a string, displayed as garbled (including Chinese). The initial analysis is that because the character stream sent by the remote server is the UTF-8 encoding of the transmitted content, and the client obtains the character stream, it resolves to the string with the JVM's default encoding, which causes the garbled problem because of inconsistent server-client encoding.
Based on experience, we know:
Java Virtual machine string encoding by default following the operating system, the Chinese version of the Windows system is encoded as Gbk,linux system UTF8, if you need to manually set the encoding, you can add the following parameters when the JVM starts:
-dfile.encoding=utf-8
New problem: After adding the above parameters, the Java program output to standard output (that is, the common console), the log encoding will be UTF8, but myeclipse console, Windows cmd window, do not know that should be UTF8 encoding to parse the JVM output characters, So will come out garbled problem.
Final Solution:
In order for the JVM output encoding to be consistent with the console receiver, the console receive encoding needs to be set manually, as in MyEclipse:
1). Click Window-preferences-myeclipse-servers-tomcat-tomcat 7.x-launch, click the ' Create Launch Configuration ' button, Create a new debug Configuration .
650) this.width=650; "Src=" http://img.blog.csdn.net/20140226143549671?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvy29saw45mq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "style=" Border:none;vertical-align:middle;margin:auto; "/>
2). In the Common tab, set encoding to Utf-8,
arguments tab, add -dfile.encoding=utf-8 parameter is in the VM startup parameter. The following two figure:
650) this.width=650; "Src=" http://img.blog.csdn.net/20140226143950453?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvy29saw45mq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "style=" Border:none;vertical-align:middle;margin:auto; "/>
650) this.width=650; "Src=" http://img.blog.csdn.net/20140226143938500?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvy29saw45mq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "style=" Border:none;vertical-align:middle;margin:auto; "/>
3). After the above steps, MyEclipse a Tomcat 7.x [custom] to use this tomcat for future debug/deployment Projects.
650) this.width=650; "Src=" http://img.blog.csdn.net/20140226144140718?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvy29saw45mq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "style=" Border:none;vertical-align:middle;margin:auto; "/>
In this way, MyEclipse, the Tomcat console is garbled and solved.
MyEclipse the Tomcat console print garbled solution