解決亂碼

 今天用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();
		}

發佈了62 篇原創文章 · 獲贊 149 · 訪問量 65萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章