jsp中文乱码问题
来源:互联网 发布:qq飞车圣殿骑士数据 编辑:程序博客网 时间:2024/05/01 15:13
解决办法:
第一:
1:在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
2:在servlet里面:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
3:上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null ¦ ¦s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
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("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
第一:
1:在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
2:在servlet里面:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
3:上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null ¦ ¦s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
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("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
- jsp中文乱码问题
- 【Jsp中文乱码问题】
- jsp 中文乱码问题
- JSP中文乱码问题
- JSP中文乱码问题
- JSP中文乱码问题
- JSP中文乱码问题
- JSP中文乱码问题
- jsp中文乱码问题
- jsp中文乱码问题
- jsp中文乱码问题
- JSP中文乱码问题
- jsp中文乱码问题
- JSP中文乱码问题
- JSP中文乱码问题
- JSP中文乱码问题
- Jsp中文乱码问题
- jsp中文乱码问题
- 世界杯精选歌曲推荐
- 《跑跑大作战II》Flash 游戏完工
- 软件的易用性总结
- oracle中用到的一些英文
- 自制
- jsp中文乱码问题
- UPnp
- 在asp.net中实现dataset与excel的相互导入导出
- 心情日记
- 心情日记
- 进京啦
- 感悟
- 找工作
- 诺基亚9300手机开发的有关资料