http://www.softwelt.com/Know/KnowDetail.aspx?Qid=220630
System.out.println(new String(str.getBytes("GBK"),"ISO8859_1"));
System.out.println(new String(str.getBytes("GBK"),"utf-8"));
System.out.println(new String(str.getBytes("GBK"),"GB2312"));
System.out.println(new String(str.getBytes("GBK"),"GBK"));
System.out.println(new String(str.getBytes("ISO8859_1"),"GBK"));
System.out.println(new String(str.getBytes("ISO8859_1"),"ISO8859_1"));
System.out.println(new String(str.getBytes("ISO8859_1"),"GB2312"));
System.out.println(new String(str.getBytes("ISO8859_1"),"utf-8"));
System.out.println(new String(str.getBytes("utf-8"),"GBK"));
System.out.println(new String(str.getBytes("utf-8"),"utf-8"));
System.out.println(new String(str.getBytes("utf-8"),"GB2312"));
System.out.println(new String(str.getBytes("utf-8"),"ISO8859_1"));
System.out.println(new String(str.getBytes("GB2312"),"GB2312"));
System.out.println(new String(str.getBytes("GB2312"),"ISO8859_1"));
System.out.println(new String(str.getBytes("GB2312"),"utf-8"));
System.out.println(new String(str.getBytes("GB2312"),"GBK"));
出现中文的就是正确的编码
然后再相应的解决就可以
1.jsp
<%@ page pageEncoding="utf-8"%>
2.request
request.setCharaterEncoding("utf-8");(可以用过滤器)
3.database url
jdbc:mysql://localhost:3306/test?userUnicode=true&characterEncoding=utf-8
4.database table
设置数据库字符集为utf-8
System.out.println(new String(str.getBytes("GBK"),"ISO8859_1"));
System.out.println(new String(str.getBytes("GBK"),"utf-8"));
System.out.println(new String(str.getBytes("GBK"),"GB2312"));
System.out.println(new String(str.getBytes("GBK"),"GBK"));
System.out.println(new String(str.getBytes("ISO8859_1"),"GBK"));
System.out.println(new String(str.getBytes("ISO8859_1"),"ISO8859_1"));
System.out.println(new String(str.getBytes("ISO8859_1"),"GB2312"));
System.out.println(new String(str.getBytes("ISO8859_1"),"utf-8"));
System.out.println(new String(str.getBytes("utf-8"),"GBK"));
System.out.println(new String(str.getBytes("utf-8"),"utf-8"));
System.out.println(new String(str.getBytes("utf-8"),"GB2312"));
System.out.println(new String(str.getBytes("utf-8"),"ISO8859_1"));
System.out.println(new String(str.getBytes("GB2312"),"GB2312"));
System.out.println(new String(str.getBytes("GB2312"),"ISO8859_1"));
System.out.println(new String(str.getBytes("GB2312"),"utf-8"));
System.out.println(new String(str.getBytes("GB2312"),"GBK"));
出现中文的就是正确的编码
然后再相应的解决就可以
1.jsp
<%@ page pageEncoding="utf-8"%>
2.request
request.setCharaterEncoding("utf-8");(可以用过滤器)
3.database url
jdbc:mysql://localhost:3306/test?userUnicode=true&characterEncoding=utf-8
4.database table
设置数据库字符集为utf-8