使用正则将url中的协议改为https /** * 将url中的协议改为https */ public static String convertUrl2Https(String url) { if(str == null || str.length() == 0){ return ""; } return url.replaceFirst("^(?:http:)?//", "https://"); }