Urldecoder:incomplete trailing escape (%) pattern problem handling

Source: Internet
Author: User

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
    1. try {
    2. PageTitle = Java.net.URLDecoder.decode (PageTitle,"UTF-8");
    3. sc = Java.net.URLDecoder.decode (SC,"UTF-8");
    4. } catch (Unsupportedencodingexception e) {
    5. E.printstacktrace ();
    6. }

The revised code is as follows:

Java code
    1. try {
    2. PageTitle = Java.net.URLDecoder.decode (Pagetitle.replaceall ("%", "%25"),"UTF-8");
    3. sc = Java.net.URLDecoder.decode (sc.replaceall ("%", "%25"),"UTF-8");
    4. } catch (Unsupportedencodingexception e) {
    5. E.printstacktrace ();
    6. }

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
  1. Function post (URL, PARAMS)
  2. {
  3. //Create a temporary form
  4. var tempform = document.createelement ("form");
  5. Tempform.action = URL;
  6. Tempform.method = "POST";
  7. TempForm.style.display = "None";
  8. //Traverse individual parameters to add a text field to the form
  9. For (var x in PARAMS)
  10. {
  11. var opt = document.createelement ("textarea");
  12. Opt.name = x;
  13. Opt.value = Params[x];
  14. Tempform.appendchild (opt);
  15. }
  16. //Add the form to the current page.
  17. Document.body.appendChild (Tempform);
  18. //Submit form.
  19. Tempform.submit ();
  20. }

This method can also be used to solve: http://blog.csdn.net/zhensoft163/article/details/7298161

Urldecoder:incomplete trailing escape (%) pattern problem handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.