這是很頭痛的問題,一直都是在困擾著我們。我有一個不算簡單也不算難的方法,這是我一直在用的方式。
1、建立一個類,包括一個格式將中文轉換為ISO8859-1編碼的方法:
publicclass Format2Chinese {
public Format2Chinese() {
}
public String format2IS08859(String str) {
try {
if (str == null str.trim().equals(""))
str = "";
else
str = new String(str.getBytes("ISO8859-1"));
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
2、你的bean里面這時就要加一些東西了,如下面這個簡單的bean:
publicclass Leavemsg
{
public Leavemsg() {
1、建立一個類,包括一個格式將中文轉換為ISO8859-1編碼的方法:
publicclass Format2Chinese {
public Format2Chinese() {
}
public String format2IS08859(String str) {
try {
if (str == null str.trim().equals(""))
str = "";
else
str = new String(str.getBytes("ISO8859-1"));
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
2、你的bean里面這時就要加一些東西了,如下面這個簡單的bean:
publicclass Leavemsg
{
public Leavemsg() {