Chinese characters garbled during URL transfer from JSP to action

Source: Internet
Author: User

Encode in JSP before Decoding in action

Encodeuri ("Chinese") Encoding

Urldecoder. Decode (request. getparameter ("parameter name"), "UTF-8"); complete decoding.

Example: URL: "qtypenums. Action? Typeid = <s: property value = 'typeid' escape = 'false'/> & qmobile = <s: property value = 'qmobile' escape = 'false'/> & QNAME = "+ encodeuri ('<s: property value = 'qname' escape = 'false'/> ') + "& qattr1 =" + encodeuri (' <s: property value = 'qattr1' escape = 'false'/> ') + "& qattr2 =" + encodeuri (' <s: property value = 'qattr2' escape = 'false'/> ') + "& qattr3 =" + encodeuri (' <s: property value = 'qattr3' escape = 'false'/> ')),

Decoding in action

String QNAME = This. getqname ();
String qattr1 = This. getqattr1 () = NULL? "": This. getqattr1 ();
String qattr2 = This. getqattr2 () = NULL? "": This. getqattr2 ();
String qattr3 = This. getqattr3 () = NULL? "": This. getqattr3 ();
String qname1 = "";
String qattr11 = "";
String qattr21 = "";
String qattr31 = "";
Try {
Qname1 = urldecoder. Decode (QNAME, "UTF-8 ");
Qattr11 = urldecoder. Decode (qattr1, "UTF-8 ");
Qattr21 = urldecoder. Decode (qattr2, "UTF-8 ");
Qattr31 = urldecoder. Decode (qattr3, "UTF-8 ");
} Catch (exception W ){}

Related Article

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.