url上的中文字符是ISO-8859-1。后台获取中文乱码解决问题。
需要转码
public static String changeCharset(String str, String defaultValue)
{
if (str != null)
{
try
{
if ((StringUtils.isNotBlank(str)) && str.equals(
new String(str.getBytes("ISO-8859-1"), "ISO-8859-1")))
{
return new String(str.getBytes("ISO-8859-1"), "UTF-8");
}
return str;
}
catch (UnsupportedEncodingException e)
{
throw new RuntimeException("字符串转换异常!!!!");
}
}
return defaultValue;
}
url上的中文字符是ISO-8859-1。后台获取中文乱码解决问题。
原文:https://www.cnblogs.com/ykpkris/p/13032662.html