<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"
</head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"
</head>
解决方案 »
- JAVA下出现的错误,什么原因引起的?
- 关于泛型的问题
- 【求助】如何用js实现点击标签之后改变标签
- 我用JQUERY获取了下拉框的文本值,想传到另一个JSP页面怎么做
- 放到子目录后,jsp里的javabean用不了,报错The value for the useBean class attribute ... is invalid.
- myeclipse连接不上数据库
- 再web页面上如何用表格动态显示数据库中取出的数据
- 加急!!!!!!jsp 怎么获取公网ip!!!!
- 真有意思啊
- 用JSP页面发邮件的一个菜问题
- 急,如何判断一个文件夹(fold)是否存在?在线等待
- JSP高手大哥,大姐们,帮帮我啊,在线等待!!!!!!!!!!
我在jsp里面这样转换编码:
str = new String(str.getBytes("utf-8"),"gb2312");
但还是乱码,不知道为什么,谢谢。
private static final String inCode = "ISO-8859-1";
private static final String outCode = "gb2312"; //到数据库时用readString(String inputString)
public static String readString(String inputString){
try {
byte[] tempByte = inputString.getBytes(inCode);
inputString = new String(tempByte,outCode);
}
catch (UnsupportedEncodingException ex) {
throw new RuntimeException("Unsupported encoding type.");
}finally{
return inputString;
}
} //显示的时候用writeString(String inputString)
public static String writeString(String inputString){
try {
byte[] tempByte = inputString.getBytes(outCode);
inputString = new String(tempByte,inCode);
}
catch (UnsupportedEncodingException ex) {
throw new RuntimeException("Unsupported encoding type.");
}finally{
return inputString;
}
}
试试看