http://blog.csdn.net/yangbobo1992/article/details/10076335
________________________________________________________
In the recently used project, the pagination page is thrown in the export Excel
Java.lang.IllegalArgumentException:URLDecoder:Incomplete trailing escape (%) pattern
The page is a DWR page, which has been collected for a while to finally become a fruition. Solutions
The general meaning is understood, we just need to pass in the background of the parameter character before decode use ReplaceAll ('% ', '%25 ') can be
Java code
- try {
- PageTitle = Java.net.URLDecoder.decode (PageTitle,"UTF-8");
- sc = Java.net.URLDecoder.decode (SC,"UTF-8");
- } catch (Unsupportedencodingexception e) {
- E.printstacktrace ();
- }
The revised code is as follows:
Java code
- 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 ();
- }
Some references from: http://dwr.2114559.n2.nabble.com/Exception-URLDecoder-Incomplete-trailing-escape-pattern-td5396332.html
Special attention:
Sometimes when you export Excel with a Get method to cause the URL string length is too long, instead of using post to solve the above problem.
Use JS to implement the Post form submission code snippet:
JS Code
- Function post (URL, PARAMS)
- {
- //Create a temporary form
- var tempform = document.createelement ("form");
- Tempform.action = URL;
- Tempform.method = "POST";
- TempForm.style.display = "None";
- //Traverse individual parameters to add a text field to the form
- For (var x in PARAMS)
- {
- var opt = document.createelement ("textarea");
- Opt.name = x;
- Opt.value = Params[x];
- Tempform.appendchild (opt);
- }
- //Add the form to the current page.
- Document.body.appendChild (Tempform);
- //Submit form.
- Tempform.submit ();
- }
This method can also be used to solve: http://blog.csdn.net/zhensoft163/article/details/7298161
Urldecoder:incomplete trailing escape (%) pattern problem handling