jsp中文显示问题可以解决了!!
jsp吧
全部回复
仅看楼主
level 1
zengdefu 楼主
我好不容易才找到方法了,相信大家对这个一样头疼.在网是找到了以下处理函数,入参是有问题的字符串,出参就是正常的字符串了.String parseChinese(String in) { String s = null; byte temp []; if (in == null) { System.out.println("Warn:Chinese null founded!"); return new String(""); } try { temp=in.getBytes("iso-8859-1"); temp=in.getBytes("iso-8859-1"); s = new String(temp); } catch(Exception e) { System.out.println("Warn:Chinese null founded!"); return new String(""); } try { temp=in.getBytes("iso-8859-1"); s = new String(temp); } catch(UnsupportedEncodingException e) { System.out.println (e.toString()); } return s; }
2004年08月24日 08点08分 1
level 1
我晕哦..用不着这么麻烦吧?一句话就搞定了的.....在语句前面加上request.setCharacterEncoding("gb2312");就行了..
2004年08月26日 13点08分 2
level 0
是撒 `,就一句话的问题!!进行一下转换就可以哒!像你这样麻烦还不要死人啊!
2004年08月27日 00点08分 3
level 1
zengdefu 楼主
你们说的也对,但上面的函数可以解决由jsp向数据库插中文记录的问题的.直接插都是些乱码!
2004年09月02日 04点09分 4
level 0
是吗,那我就抄下来了.
2006年01月20日 07点01分 5
level 0

2006年01月20日 12点01分 6
level 0
你用的什么数据库啊?我觉得数据库的编码设置成中文(gb2312)就可以了,输出的时候用request.setCharacterEncoding("gb2312");绝对没问题.我用mysql遇到这样的乱码问题过,就是这么解决的.
2006年01月24日 11点01分 7
1