Java intercepts url parameters. java intercepts URLs.

Source: Internet
Author: User
Tags lzf

Java intercepts url parameters. java intercepts URLs.

/*** Remove the path from the url and leave the request parameter Section * @ param strURL url address * @ return url request parameter Section * @ author lzf */private static String TruncateUrlPage (String strURL) {String strAllParam = null; String [] arrSplit = null; strURL = strURL. trim (). toLowerCase (); arrSplit = strURL. split ("[?] "); If (strURL. length ()> 1) {if (arrSplit. length> 1) {for (int I = 1; I <arrSplit. length; I ++) {strAllParam = arrSplit [I] ;}}return strAllParam;}/*** parse the key-value pairs in url parameters * such as "index. jsp? Action = del & id = 123 ", parse Action: del, id: 123 save to map * @ param URL url address * @ return url request parameter Section * @ author lzf */public static Map <String, String> urlSplit (String URL) {Map <String, String> mapRequest = new HashMap <String, String> (); String [] arrSplit = null; String strUrlParam = TruncateUrlPage (URL ); if (strUrlParam = null) {return mapRequest;} arrSplit = strUrlParam. split ("[&]"); for (String strSplit: arrSplit) {Stri Ng [] arrSplitEqual = null; arrSplitEqual = strSplit. split ("[=]"); // parse the key value if (arrSplitEqual. length> 1) {// parse mapRequest correctly. put (arrSplitEqual [0], arrSplitEqual [1]);} else {if (arrSplitEqual [0]! = "") {// Only the parameter has no value. mapRequest. put (arrSplitEqual [0], "") ;}} return mapRequest;} is not added ;}

 

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.