spring MVC Action裏面怎麼設置UTF-8編碼集

/* 編碼轉換,確保寫數據庫的時候不會出現亂碼 */
public class CodingConvert{ public CodingConvert(){ //  } public String toGb(String uniStr) { String gbStr = ""; if (uniStr == null) { uniStr = ""; } try { byte[] tempByte = uniStr.getBytes("ISO8859_1"); gbStr = new String(tempByte, "UTF-8"); } catch (Exception ex) { } return gbStr; } public String toUni(String gbStr) { String uniStr = ""; if (gbStr == null) { gbStr = ""; } try { byte[] tempByte = gbStr.getBytes("UTF-8"); uniStr = new String(tempByte, "ISO8859_1"); } catch (Exception ex) { } return uniStr; } }
相關文章
相關標籤/搜索