URLDecoder: Incomplete trailing escape (%) pattern问题处理
项目中字典框中添加了%,会弹出错误信息,经调试代码后发现在DictioaryAction.java类中,进行如下代码时报错:
searchString=URLDecoder.decode(searchString,"utf-8");
网上查找资料显示,当最后一个字符为“%”时,URLDecoder类会抛出异常java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern,而“%”出现在字符中间时,执行正常,进行如此更改即可。
searchString=URLDecoder.decode(searchString.replaceAll("%", "%25"),"utf-8");