Chinese characters in URL parameters converted to 16 Unicode form

Source: Internet
Author: User

To import a jar package:
Import java.net.*;
Convert kanji into 16 Unicode form:
String xw= "News Center";
String Name=urlencoder.encode (XW, "utf-8");
Converts a 16-binary Unicode form string to a Chinese character:
Urldecoder.decode ("%e6%96%b0%e9%97%bb%e4%b8%ad%e5%bf%83", "utf-8");

Note: When jumping to page B from a (UTF-8) page: Parameter name with 16 binary parameter value, used in page B, Request.getparameter () gets the parameter is garbled. You cannot use Urldecoder.decode (name, "Utf-8") or access the "News Center";
Add:
on page A:
<%
String xw= "News Center";
String Name=urlencoder.encode (XW, "utf-8");
Request.setparameter ("name", "name");%>
In the B page:
<%
String Xw=urldecoder.decode (New String (Request.getparameter ("name"). GetBytes ("Iso-8859-1"), "Utf-8"), "Utf-8"); > So there will be no garbled.

Chinese characters in URL parameters converted to 16 Unicode form

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.