宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

今天做项目构造链接参数的时候,推送到app上的链接点了没办法跳转到对应的界面
对比了一下能跳转的链接,原来是url没有加密,就推送过去了
在这里把对url加密解密的方法记录一下,方便以后使用

public static String getURLEncoderStringString str) { 
   
    String result = "";
    if null == str) { 
   
        return "";
    }
    try { 
   
        result = java.net.URLEncoder.encodestr, "UTF-8");
    } catch UnsupportedEncodingException e) { 
   
        e.printStackTrace);
    }
    return result;
}

public static String URLDecoderStringString str) { 
   
    String result = "";
    if null == str) { 
   
        return "";
    }
    try { 
   
        result = java.net.URLDecoder.decodestr, "UTF-8");
    } catch UnsupportedEncodingException e) { 
   
        e.printStackTrace);
    }
    return result;
}

Jetbrains全家桶1年46,售后保障稳定