Talk less, and went straight to the key code.
The specific code looks like this:
/** * Remove the path in the URL, leaving the request parameter part * @param strurl URL address * @return URL request parameter part * @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; /** * resolves the key values in the URL parameter to * such as "index.jsp?" Action=del&id=123 ", parse out action:del,id:123 into map * @param URL url address * @return URL request parameter part * @author LZF/public static Ma P<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) {string[] arrsplitequal=null;
Arrsplitequal= strsplit.split ("[=]"); Parse out the key value if (arrsplitequal.length>1) {//parse Maprequest.put correctly (arrsplitequAl[0], arrsplitequal[1]);
}else{if (arrsplitequal[0]!= "") {//Only parameter has no value, does not join Maprequest.put (arrsplitequal[0], "");
}} return maprequest; }
Ps:java intercept the value in the URL
Map<string, object> urlsplit (String data) {
StringBuffer strbuf = new StringBuffer ();
StringBuffer strbuf2 = new StringBuffer ();
map<string,object> map = new hashmap<string,object> ();
for (int i =0;i<data.length (); i++) {
if (data.substring (i,i+1). Equals ("=")) {for
(int n=i+1;n< Data.length (); n++) {
if (data.substring (n,n+1). Equals ("&") | | n ==data.length ()-1) {
map.put ( Strbuf.tostring (), strbuf2);
Strbuf =new StringBuffer ("");
Strbuf2 =new StringBuffer ("");
I=n;
break;
Strbuf2.append (data.substring (n,n+1));
}
Continue;
}
Strbuf.append (data.substring (i,i+1));
}
return map;
}
The above is a small set up to introduce the Java method of intercepting URL parameters and Java interception URL value method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!