使用URLDecoder.decode() 方法接收参数时如果参数中含有“%”这个字符,就会抛异常 java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern -,
大致意思都懂了,我们只需要将传入后台的参数字符在decode之前使用replaceAll('%','%25')一下即可
try {
pageTitle = java.net.URLDecoder.decode(pageTitle.replaceAll("%", "%25"),"UTF-8");
sc = java.net.URLDecoder.decode(sc.replaceAll("%", "%25") ,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Comments | NOTHING