u盘容量鉴定软件:jsp中的乱码问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/20 21:17:22
各位大大,帮下菜鸟吧。
一个修改页面,提交之后显示的是乱码。
我已经在页面开头加
<%@ page contentType="text/html; charset=gb2312" %>
处理表单的也加
request.setCharacterEncoding("gb2312"); 这一句了。
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">在<head>之间也加上这一句了。可是提交修改后刚才改过的内容就显示乱码呢?还有,如果我将request.setCharacterEncoding("gb2312"); 这句去掉的话,有一项可以显示中文,另一项却不行。加上这句则又反过来。哪位好心人帮帮我。谢谢了。

给你一个java bean
package classname;
public class Chg{
public String chgstr(String str){
try {
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String (temp_t);
return temp;
}
catch(Exception e){
return null;
}
}
}

把"GB2312"换成"GBK"试试呢?