HTML提交form表单,向servlet传中文时,乱码,不知道该怎么解决?急啊
PrintWriterout=response.getWriter();request.setCharacterEncoding("gbk");response.setC...
PrintWriter out=response.getWriter();
request.setCharacterEncoding("gbk");
response.setCharacterEncoding("gbk");
String nickname=request.getParameter("gb_nickname");
int length=getInfo.getMessLengh();
String id=""+(length+1);
String head=request.getParameter("gb_head");
String tel=request.getParameter("gb_tel");
String title=request.getParameter("gb_title");
String qiaoqiao=request.getParameter("gb_qiaoqiaohua");
String content=request.getParameter("gb_content");
String time=getInfo.getTime();
if(nickname!=null&&title!=null&&content!=null)
{ // nickname=new String(nickname.getBytes("iso8859-1"),"UTF-8");
title=new String(title.getBytes("iso8859-1"));
content=new String(content.getBytes("iso8859-1"));
nickname = new String(nickname.getBytes("iso-8859-1"),"gb2312");
}
out.println("hello");
out.println(nickname);
out.println(title);
out.println(content);
输出汉字是乱码 展开
request.setCharacterEncoding("gbk");
response.setCharacterEncoding("gbk");
String nickname=request.getParameter("gb_nickname");
int length=getInfo.getMessLengh();
String id=""+(length+1);
String head=request.getParameter("gb_head");
String tel=request.getParameter("gb_tel");
String title=request.getParameter("gb_title");
String qiaoqiao=request.getParameter("gb_qiaoqiaohua");
String content=request.getParameter("gb_content");
String time=getInfo.getTime();
if(nickname!=null&&title!=null&&content!=null)
{ // nickname=new String(nickname.getBytes("iso8859-1"),"UTF-8");
title=new String(title.getBytes("iso8859-1"));
content=new String(content.getBytes("iso8859-1"));
nickname = new String(nickname.getBytes("iso-8859-1"),"gb2312");
}
out.println("hello");
out.println(nickname);
out.println(title);
out.println(content);
输出汉字是乱码 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询