Java Web Chinese garbled solution

Source: Internet
Author: User

garbled situation by HTTP request can be divided into three kinds

  1. POST, this garbled is in fact the easiest to solve, in spring, for example, set the filter to cast the character encoding UTF-8 can be.

  2. get, Chinese characters in the URL string.

    workaround one: transcode the parameter values in the background

    workaround three: client like JS Call the encodeURI method to pass the parameter transcoding again.

    I think this is the best solution, which can effectively compensate for the shortcomings of the previous two methods. The service side wants to add the decoded portion, Urldecoder.decode (str, "UTF-8").

    ps:js transcoding to call two encodeURI, while the flex client needs to be called only once.

  3. Post Upload file

    Why take this alone? Because the upload request information contains two parts, one is the request body, which is the part that sends the binary data of the file. The other is the attribute parameters, such as file name, and so on, these parameters are similar to get, is sent with the URL, so if the traditional post processing, the file name garbled is not resolved. Then you should apply the get workaround here.

Java Web Chinese garbled solution

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.