通过GET/POST传“中文字串”时的问题???

pantech_36 2002-12-16 07:14:55
现在通过GET传“中文字串”在得到值的页面第一次输出为乱符。刷新后就正常了怎么回事呢?请指教!还有GET与POST处理中文字串是否一样?
redirct.jsp?str=中文字串
在redirct.jsp代码中如下输出
String temp_str= new String(request.getParameter("str").getBytes("ISO8859_1"),"GB2312");
out.print(temp_str);
有<%@page contentType="text/html;charset=gb2312"%>
...全文
43 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxl19790710 2002-12-17
  • 打赏
  • 举报
回复
public static String Ch(String in){
String s = null;
byte[] temp;
if (in == null){
System.out.println("Warn:Chinese null found!");
return new String("");
}
try{
temp=in.getBytes("iso-8859-1");
s= new String(temp);
}catch(Exception e){
System.out.println (e.toString());
}
return s;
}


/**
* 功 能:转换成iso8859-1
*/
public static String deCh(String in){
String s = null;
if (in == null){
System.out.println("Warn:Chinese null found!");
return new String("");
}
try{
s=new String(new String(in).getBytes("GBK"),"ISO8859_1");
}catch(Exception e){
System.out.println (e.toString());
}
return s;

}
littleyy 2002-12-17
  • 打赏
  • 举报
回复
<% response.setHeader("Cache-Control", "no-cache"); %>
zxhong 2002-12-17
  • 打赏
  • 举报
回复
删除tomcat/work/
下的东东
重启服务器!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧