使用的是springboot, 對應tomcat 8.5.3,tomcat默認編碼ISO8859-1所以需要轉碼成UTF-8.
tomcat 8之後版本默認編碼爲UTF-8.
try {
if (StringUtils.isNotBlank(reason) && reason.equals(new String(reason.getBytes("ISO8859-1"), "ISO8859-1"))) {
reason = new String(reason.getBytes("ISO8859-1"), "UTF-8");
}
} catch (UnsupportedEncodingException e) {
throw e;
}