今天用struts读取.properties文件再在页面上显示时乱码
byte[] bs = null;
try {
String sourceString = getText("NoticeOfGreateThanMaxAllowUserCount");
System.out.println(sourceString);//乱码
bs = sourceString.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
String target;
try {
target = new String(bs,"UTF-8");
System.out.println(target);//没有乱码了
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}