An error occurred while running the xml encoding format in tomcat. There is no problem in eclipse. tomcateclipse

Source: Internet
Author: User

An error occurred while running the xml encoding format in tomcat. There is no problem in eclipse. tomcateclipse

There is no problem in running it directly in eclipse. An error is reported when it is published to tomcat.

All are set to UTF8 encoding .....

Xml data with Chinese error:

Com.sun.org. apache. xerces. internal. impl. io. MalformedByteSequenceException: 2 words
The byte 2 of the UTF-8 sequence of the section is invalid.

Xml data does not contain Chinese characters:

Com.sun.org. apache. xerces. internal. impl. io. MalformedByteSequenceException: 1 word
The byte 1 of the UTF-8 sequence of the section is invalid.

Solution:

Add a sentence to the catalina. bat configuration file.

Set JAVA_OPTS =-server-Dfile. encoding = UTF-8

Run with UTF-8 encoding


System Code problems found later

The utf8 parameter must be included in the md5 encryption process of the payment signature; otherwise, the gbk encoding method will be used.

ResultString = byteArrayToHexString (md. digest (resultString. getBytes ("UTF-8"); // the correct method

Refer:

Http://blog.csdn.net/yjg428/article/details/44107667

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.