你不就是为了处理显示日文吗?
日问的编码是:Shift_JIS
解决办法:
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=Shift_JIS" %>
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=Shift_JIS");
上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"Shift_JIS");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("Shift_JIS"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
日问的编码是:Shift_JIS
解决办法:
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=Shift_JIS" %>
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=Shift_JIS");
上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"Shift_JIS");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("Shift_JIS"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
谢谢