只适用于简单的url,特殊字符或转义会导致获取不到正确参数
自定义获取参数方法,也可将参数放入响应头中
import org.apache.cxf.common.util.UrlUtils;
import java.net.URL;
public class Main{
public static void main(String[] args) {
try {
String urlStr = "https://localhost:8080/test?param=UTF-8&fileName=test.jpg";
URL url = new URL(urlStr);
Map<String, String> paramMap = UrlUtils.parseQueryString(url.getQuery());
System.out.println(paramMap);
} catch (Exception e) {
e.printStackTrace();
}
}
}
网友评论