方式一
final String queryString = request.getQueryString();
System.out.println(queryString);
//解码
System.out.println(URLDecoder.decode(queryString, StandardCharsets.UTF_8));
测试:
pageSize=25&pageNum=1&sort%5B%27id%27%5D=desc&sort%5B%27name%27%5D=asc&keywords=&state=-1
pageSize=25&pageNum=1&sort%5B%27id%27%5D=desc&sort%5B%27name%27%5D=asc&keywords=&state=-1
pageSize=25&pageNum=1&sort['id']=desc&sort['name']=asc&keywords=&state=-1
方式二
Map<String, String[]> params = request.getParameterMap();
for (Map.Entry<String, String[]> param : params.entrySet()) {
String key = param.getKey(); // 参数名
String[] value = param.getValue(); // 参数值
System.out.println(key + " - " + Arrays.toString(value));
}
测试
pageSize=25&pageNum=1&sort%5B%27id%27%5D=desc&sort%5B%27name%27%5D=asc&keywords=&state=-1
pageSize - [25]
pageNum - [1]
sort['id'] - [desc]
sort['name'] - [asc]
keywords - []
state - [-1]
标签:27%,pageSize,5B%,url,sort%,获取,参数,keywords,5D
From: https://blog.51cto.com/lianghecai/7693271