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();
}
解決亂碼
今天用struts讀取.properties文件再在頁面上顯示時亂碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.