How to Use encodeURI of JS and URLDecoder. decode of java

Source: Internet
Author: User

If you do not want to see any text in the url, such as http: // localhost: 8080/template_1/login. action? User = James

You can use URLDecoder. decode of encodeURI of js to encrypt the url.

(1) JS sets the data var val = encodeURI ("value to be uploaded to the server") on the page; // calls encodeURI twice

Href = "<% = basePath %> recordManager/test_js_decodeURI.action? Params = "+ val

(2) server side
Copy codeThe Code is as follows:
HttpServletRequest request = ServletActionContext. getRequest ();
String vString = request. getParameter ("params ");
System. out. println ("before conversion:" + vString );
String deString = URLDecoder. decode (vString, "UTF-8 ");
System. out. println ("converted:" + deString );

The UTF-8 is consistent with the Code on the page, for example: pageEncoding = "UTF-8" on the jsp page here is the UTF-8

Right-click on ie to see if pageEncoding = "UTF-8" ie on jsp right-click encoding uncode (UTF-8) If pageEncoding = "GBK" on jsp ", then, right-click on ie (Simplified Chinese gb2312)

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.