方式一
java
final String queryString = request.getQueryString();
System.out.println(queryString);
//解码
System.out.println(URLDecoder.decode(queryString, StandardCharsets.UTF_8));
测试:
java
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
方式二
java
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));
}
测试
java
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]