Moins non-sens, allez directement au code clé.
Le code spécifique est le suivant:
/ *** Supprimez le chemin dans l'URL et laissez la pièce du paramètre de demande * @param Strurl URL Adresse * @return URL Demande Paramètre Part * @Author LZF * / Private Static String TuncateUrlPage (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 ++) {stallparam = arrsplit [i] Retour Strallparam; } / *** analyser les paires de valeurs clés dans les paramètres URL * Par exemple, "index.jsp? Action = del & id = 123", analyser l'action: del, id: 123 stocké dans la carte * @param adresse URL * @return URL Demande Paramètre Part * @author lzf * / Public Static Map <String, String> UrlSpli MapRequest = new HashMap <String, String> (); String [] Arrsplit = NULL; String StrurlParam = TruncAverlPage (url); if (strurlparam == null) {return maprequest;} arrsplit = strurlparam.split ("[&]"); pour (string strsplit: artsplit) {string) arrsplitequal = null; ArrSplitequal = strsplit.split ("[=]"); // analyser la valeur clé if (arrsplitequal.length> 1) {// analyser correctement maprequest.put (arrsplitequal [0], Arrsplitequal [1]);} else {if (Arrsplitequal [0]! = "") { MapRequest.put (Arrsplitequal [0], ""); }}} return MapRequest; }PS: Java intercepte la valeur de l'URL
Map <string, object> urlsplit (string data) {stringBuffer strbuf = new StringBuffer (); stringBuffer strbuf2 = new StringBuffer (); map <string, objet> map = new hashmap <string, objet> (); 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));} retour de la carte;}Ce qui précède est la méthode d'interception des paramètres d'URL en Java et la méthode d'interception des valeurs d'URL en Java. J'espère que ce sera utile à tout le monde. Si vous avez des questions, veuillez me laisser un message et l'éditeur répondra à tout le monde à temps. Merci beaucoup pour votre soutien au site Web Wulin.com!