我在客户做系统维护,一直很正常,今天重新启动了一下服务器上的weblogic,然后就在后台增加内容的时候出现
URLDecoder: Incomplete trailing escape (%) pattern 错误,但是我在自己的电脑上用tomcat跑起来又没任何问题,请问是什么原因???

解决方案 »

  1.   

    HTTP请求字符串的URLDecoder发生错误了我以前也遇到过此类问题,不过是字符集(utf-8,unicode等)的URLDecoder解码问题
      

  2.   

    字符解析出了问题,看看你传的参数有没有问题,如果参数中含有%,把%替换一下,
    下面的这个是我一直用的方法,可能会有漏洞,但对大部份url还是可以的, public static String enCodeURL(String url,String code){
    if(!StringUtil.isFine(url))
    return null;
    Pattern pattern = Pattern.compile("[\u300a\u300b]|[\u4e00-\u9fa5]|[\uFF00-\uFFEF]",Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
    Matcher m = pattern.matcher(url);
    if(m.find()){
    int get=m.start();
    String suburl=url.charAt(get)+"";
    String encodesuburl="";
    try{encodesuburl=URLEncoder.encode(suburl,code);}catch(Exception e){}
    url=url.replaceAll(suburl,encodesuburl);
    url=enCodeURL(url,code);
    }
    url=url.replaceAll(" ","20%");
    return url;
    }