/** ??* URL中文字符编码转换 ??* @param url 含中文字符的URL ??* @return ???*/ ?public static String getChineseURICode(String url){ ?????if(ValidateUtil.isEmpty(url)) throw new AppException("URL cannot be null"); ?????Matcher matcher = Pattern.compile("[\u4e00-\u9fa5]").matcher(url); ?????String c = null; ?????URLEncoder urlEncoder = new URLEncoder(); ?????while (matcher.find()) { ?????????c = matcher.group(); ?????????url = url.replaceAll(c,urlEncoder.encode(c)); ?????} ?????return url; ?}
url中含有中文路径时访问出现404问题
原文地址:https://www.cnblogs.com/feiruo/p/8405968.html