URLDecoder: Incomplete trailing escape (%) pattern问题处理
http://blog.csdn.net/yangbobo1992/article/details/10076335
________________________________________________________
最近在用的项目中,分页页面在导出excel抛出
java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern
该页面采用的是DWR分页,经过一番搜罗,终于修成正果.解决办法
大致意思都懂了,我们只需要将传入后台的参数字符在decode之前使用replaceAll('%','%25')一下即可
- try {
- pageTitle = java.net.URLDecoder.decode(pageTitle,"UTF-8");
- sc = java.net.URLDecoder.decode(sc ,"UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
修正后代码如下:
- 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();
- }
特别注意:
有些时候导出excel时采用的是get方式导致URL字符串长度过长,改用POST方式可以解决以上问题。
使用js实现POST表单提交代码片段:
- function post(URL, PARAMS)
- {
- //创建一个临时表单
- var tempForm = document.createElement("form");
- tempForm.action = URL;
- tempForm.method = "post";
- tempForm.style.display = "none";
- //遍历各个参数,将文本域添加至表单中
- for (var x in PARAMS)
- {
- var opt = document.createElement("textarea");
- opt.name = x;
- opt.value = PARAMS[x];
- tempForm.appendChild(opt);
- }
- //将表单添加至当前页面中.
- document.body.appendChild(tempForm);
- //提交表单.
- tempForm.submit();
- }
也可参照此方法解决:http://blog.csdn.net/zhensoft163/article/details/7298161
URLDecoder: Incomplete trailing escape (%) pattern问题处理的更多相关文章
- URLDecoder: Incomplete trailing escape (%) pattern
在使用URLDecoder对字符串进行解码的时候 报以下异常信息: Exception in thread "main" java.lang.IllegalArgumentExce ...
- URLDecoder: Illegal hex characters in escape (%) pattern - For input string
原因:后台发布文章的时候,内容里面有%,导致后台URLDecoder.decode()转码的时候报错. 看了java.net.URLDecoder的decode()的源码,原来是转码错误. 贴出部分代 ...
- java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: " 0"
value = URLDecoder.decode(request.getParameter(paraName), "UTF-8"); 前端用了 encodeURI 来编码参数,后 ...
- java转换编码报错java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern
Exception in thread "main" java.lang.IllegalArgumentException: URLDecoder: Illegal hex cha ...
- java上传附件含有%处理或url含有%(URLDecoder: Illegal hex characters in escape (%) pattern - For input string)
在附件名称中含有%的时候,上传附件进行url编码解析的时候会出错,抛出异常: Exception in thread "main" java.lang.IllegalArgumen ...
- URLDecoder异常Illegal hex characters in escape (%)
URLDecoder对参数进行解码时候,代码如: URLDecoder.decode(param,"utf-8"); 有时候会出现类似如下的错误: URLDecoder异常Ille ...
- URLDecoder异常解决方法
URLDecoder对参数进行解码时候,代码如: URLDecoder.decode(param,"utf-8"); 有时候会出现类似如下的错误: URLDecoder异常Ille ...
- URL编码 URLEncoder 示例
2016-12-27 对字符编码时的规则 通常如果一样东西需要编码,说明这样东西并不适合传输.原因多种多样,如Size过大,包含隐私数据. 对于Url来说,之所以要进行编码,一个是因为Url中有些字符 ...
- JAVA判断URL地址是否非法
/** * 判断请求url是否非法 * @param url * @return */ public static boolean isValidRequestUri(String url) { if ...
随机推荐
- xmpp 服务器配置 open fire for windows 及 spark 测试
xmpp 服务器配置 open fire for windows 此文章为 XMPP windows服务器配置,使用的是 open fire 3.9.1.exe 1: 下载 open fire ope ...
- struts脚本调用action,页面第一次访问不调用
result type 如果是默认 第一次访问页面不会访问action,刷新才会请求 type=redirect 第一次访问会直接访问action 或者在调用地址加 url?+随机数
- IOS8 Playground介绍
一.Playground介绍 Playground是Xcode6中自带的Swift代码开发环境.俗话说"功欲善其事,必先利其器".曾经在Xcode5中编写脚本代码,比如编写JS,其 ...
- 算法笔记_016:凸包问题(Java)
目录 1 问题描述 2 解决方案 2.1 蛮力法 1 问题描述 给定一个平面上n个点的集合,它的凸包就是包含所有这些点的最小凸多边形,求取满足此条件的所有点. 另外,形象生动的描述: (1)我们可以把 ...
- 多语言 SEO
https://productforums.google.com/forum/?hl=zh-CN#!topic/webmaster-zh-cn/I0MMsm737pc
- PostgreSQL远端访问
PostgreSQL默认的理念是运行在本地地址且不允许外部访问的. 如果想通过Navicat for postgreSql这种优秀的第三方软件访问需要做出如下修改: 一.启动在外部可访问的地址上 编辑 ...
- 用Reflector for .NET反编译dll文件(.net),把整个dll导出个cs插件
Reflector for .NET 下载地址: http://www.aisto.com/roeder/dotnet/ Reflector.FileDisassembler.zip下载地址: htt ...
- HDU 5186 zhx's submissions (进制转换)
Problem Description As one of the most powerful brushes, zhx submits a lot of code on many oj and mo ...
- intelliJ IDEA 配置MySQL数据库 详解
1> 在主界面中,点击右边侧栏的 Database ,在点击 + ,再Data Source 选择数据库 2> 填入 Database 数据库名,在输入 User 和 Password ...
- PHP部分常见算法
撰于:http://blog.csdn.net/caleng/article/details/5276403