急:中文乱码 要用过滤器(filter)过虑一下。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如何使用过滤器(filter)过虑 中文做参数传递时,会转换成ISO8859-1.所以要用getBytes(GB2312)进行转换一下。送你一段JavaBean吧/** * Title: 含有中文的字符串转换成能正常显示中文的字符串 * * Description: --beans scope 推荐: "page"或"application" * **/public class tranChinese { public String toChinese(String s) { if (s != null) { try { return new String(s.getBytes("iso-8859-1"), "GB2312"); } catch (java.io.UnsupportedEncodingException e) { System.out.println(e.toString()); } } return s; }public String toUnicode(String s) { if (s != null) { try { return new String(s.getBytes("GB2312"), "iso-8859-1"); } catch (java.io.UnsupportedEncodingException e) { System.out.println(e.toString()); } } return s; }} 处理提交信息的页面头加入下面语句:request.setCharacterEncoding("GBK"); jquery的问题 非常气愤!!websphere 6 为什么会放弃我的第一个sessionId? SSH做一个OA系统,怎么实现当前用户修改自己的密码? TOMCAT配置的奇怪问题,高手进来指点下 如何把java web文件做成安装文件? 这么容易得100分,难道你不想进来看看吗? 为什么我上传文件老是出错? QQ群1812975,有兴趣的进来!! 高手来讨论一下:OA中如何处理公文流转,如何定义工作流。 难道真的没有人知道Servlet里怎样把抛出的异常指定到某个页面吗? linux下有哪些web服务器可以支持ejb? 再问<html:select>
送你一段JavaBean吧
/**
* Title: 含有中文的字符串转换成能正常显示中文的字符串
*
* Description: --beans scope 推荐: "page"或"application"
*
**/public class tranChinese
{
public String toChinese(String s)
{
if (s != null)
{
try
{
return new String(s.getBytes("iso-8859-1"), "GB2312");
}
catch (java.io.UnsupportedEncodingException e)
{
System.out.println(e.toString());
}
}
return s;
}public String toUnicode(String s)
{
if (s != null)
{
try
{
return new String(s.getBytes("GB2312"), "iso-8859-1");
}
catch (java.io.UnsupportedEncodingException e)
{
System.out.println(e.toString());
}
}
return s;
}
}