从mysql读出来的中文数据为乱码,有什么办法解决?
php是用mysql_query( "set names 'gbk ' ")读中文的。JSP有类似的功能吗?
还有一个问题,JSP怎么包含另外一个文件呢?是import还是include?
------解决方案--------------------Java要读出后进行转码
public class HelloWorld
{
public static void main(String[] argv){
try{
System.out.println( "中文 ");//1
System.out.println( "中文 ".getBytes());//2
System.out.println( "中文 ".getBytes( "GB2312 "));//3
System.out.println( "中文 ".getBytes( "ISO8859_1 "));//4
System.out.println(new String( "中文 ".getBytes()));//5
System.out.println(new String( "中文 ".getBytes(), "GB2312 "));//6
System.out.println(new String( "中文 ".getBytes(), "ISO8859_1 "));//7
System.out.println(new String( "中文 ".getBytes( "GB2312 ")));//8
System.out.println(new String( "中文 ".getBytes( "GB2312 "), "GB2312 "));//9
System.out.println(new String( "中文 ".getBytes( "GB2312 "), "ISO8859_1 "));//10
System.out.println(new String( "中文 ".getBytes( "ISO8859_1 ")));//11
System.out.println(new String( "中文 ".getBytes( "ISO8859_1 "), "GB2312 "));//12
System.out.println(new String( "中文 ".getBytes( "ISO8859_1 "), "ISO8859_1 "));//13
}
catch(Exception e){
e.printStackTrace();
}
}
}