Javaweb background transcoding

Source: Internet
Author: User
Tags form post

Why do I need to transcode?

Four scenarios where the client sends a request to the server: 1, direct access to the URL method; 2, the page link (belongs to get request); 3. Form get Submit ; 4. Form Post Submission

1.url (URL and page link): Each big browser, each operating system of the URL Uri, querystring encoding may be different . Tomcat decoding of URIs is the first to get the connector of the decoder set,

the configuration is in Server.xml , <connector uriencoding="Utf-8"/> is parsed with the default encoding iso-8859-1 if not defined.

2, form: Send the request is based on the set of CharSet encoding, decoding, get mode according to the settings of uriencoding, post mode is still based on the charset of the page setup.

@ Reference article

Jetty default is Utf-8. Jetty and Unlike Tomcat, which is not modified in the XML configuration file, it can be added to the JVM parameters: Dorg.mortbay.util.URI.charset= character encoding @ Reference article

How do I transcode?

Iso-8859-1 Turn Utf-8

String Args=new string (Request.getparameter ("args". GetBytes ("Iso8859-1"), "Utf-8");

Javaweb background transcoding

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.