Commit 0f1f42a5 authored by yanzg's avatar yanzg

接口文档的支持

parent b3495d75
......@@ -4,9 +4,7 @@ import com.yanzuoguang.util.contants.SystemContants;
import com.yanzuoguang.util.exception.CodeException;
import java.net.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.*;
/**
* 地址字符串处理
......@@ -138,4 +136,56 @@ public class UrlHelper {
url = UrlHelper.dealWithUrl(url);
return url;
}
/**
* 解析出url请求的路径,包括页面
*
* @param strURL url地址
* @return url路径
*/
public static String getPage(String strURL) {
strURL = StringHelper.getFirst(strURL);
int pos = strURL.indexOf("?");
if (pos > -1) {
return strURL.substring(0, pos);
}
return strURL;
}
/**
* 去掉url中的路径,留下请求参数部分
*
* @param strURL url地址
* @return url请求参数部分
*/
private static String getQueryString(String strURL) {
strURL = StringHelper.getFirst(strURL);
int pos = strURL.indexOf("?");
if (pos > -1) {
return strURL.substring(pos + 1);
}
return StringHelper.EMPTY;
}
/**
* 解析出url参数中的键值对
* 如 "index.jsp?Action=del&id=123",解析出Action:del,id:123存入map中
*
* @param strURL url地址
* @return url请求参数部分
*/
public static Map<String, String> getQueryObject(String strURL) {
String strUrlParam = getQueryString(strURL);
Map<String, String> mapRequest = new HashMap<>();
//每个键值为一组 www.2cto.com
String[] arrSplit = strUrlParam.split("&");
for (String strSplit : arrSplit) {
String[] arrSplitEqual = strSplit.split("=");
//解析出键值
if (arrSplitEqual.length > 1) {
mapRequest.put(arrSplitEqual[0], arrSplitEqual[1]);
}
}
return mapRequest;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment