IDEA项目,多个Service Module,Service注入采用Beans xml配置文件的方式,web.xml引入该xml配置。
项目启动,打断点,调用service方法,发现bocClientConfig的某个参数,中文乱码;
参数配置,中文不多,暂时使用以下这种方式解决乱码问题;
/**
* xml注入参数中文乱码,Java默认以ISO8859-1编码读取配置
*
* @param convertStr
* @return
*/
public static String getStrFromProperties(String convertStr) {
String str = "";
try {
byte[] b_iso88591 = convertStr.getBytes("ISO8859-1");
str = new String(b_iso88591, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return str;
}
2020-09-04
可以考虑,pom文件中的值为中文的参数,将其转为Base64编码配置在pom中, 调用的时候再解码