url上的中文字符是ISO-8859-1。后台获取中文乱码解决问题。


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;
    }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM