好久没有散分了,大家结分!!!! 哈哈,以前我也遇到过的~用getbytes()可以搞定,设置contenttpye 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 大概这是菜鸟的通病吧,我当初也遇到过不过后来转行了就再也没时间用jsp了 我来帮你解决,不过,记着多给点分!1.配置web.xml <filter> <filter-name>Set Character Encoding</filter-name> <filter-class>com.erp.common.SetEncodeFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>Set Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>2.<filter-class>com.erp.common.SetEncodeFilter</filter-class>所指路径增加SetEncodeFilter类,这个类可以参考tomcat的一个SetEncodeFilter类,考过来就可以用了。 我原来使用MYSQL时出现过乱码,后来在连接数据库时加了这句就好了useUnicode=true&characterEncoding=gb2312 嗯刚做jsp的人都是这样的哈哈 散分有利于健康,大家都来散吧,hoho. ^_^ 中文乱码问题,问得很多的,到www.chinajavaworld.com的论坛搜搜吧。 to h2dog(黄兴礼): 你的方法能不能具体点,我这么理解试过了,好像不行, 你是说这么用吗 ? String strInfoTitle 是插入表前的字段值 也就是说 strInfoTitle 这个值我已经得到了,但是现在要用下面的方法处理一下, 不过结果不理想 strInfoTitle = new String(strInfoTitle.getBytes("GB2312"));----------------------------------to BigHill(山河水): 你说的这个方法中,那个tomcat的一个SetEncodeFilter类我怎么没有找到啊 ? 能不能告诉我在哪里能找到?给分没有问题,我可以另开一个帖子给分!----------------------------------to all :感谢大家把我的问题顶上去,来者皆有分哟 ! 这个问题如果可以顺利解决,我会总结整理出来,方便以后类似问题的解决! 存数据库之前调用下面的方法。例如:"insert into table (…,field1,…) values (…,'" + class.encode(value1) + "',…) " /** * 转成ISO-8859-1编码 * @param str * @return */ public static String encode(String str) { String s; try { String tempStr = str; byte tempByte[] = tempStr.getBytes("ISO8859-1"); String temp = new String(tempByte); String s1 = temp; return s1; } catch (Exception e) { s = ""; } return s; } NND你给不给分啊?建议,以后说散分但不结贴的麻烦版主封ID 关于jsp的一个问题 mysql数据库问题 j2ee项目中加入android 包能不能调用它的api?从而读取手机的信息? java线程问题/算法。 javamail 那里可以下到 三大框架(strut2+spring+hibernate) 项目视频 如何获取struts-config中的数据源(不想在Action中获得) 求助:怎么实现JTable的多行表头??? 用Document解析xml的时候,用parse()怎么获得当前的uri? 关于实现xml:space= "preserve"的问题,帮忙帮忙。。。。。。 求助 struts 问题
1.配置web.xml
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>com.erp.common.SetEncodeFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>2.<filter-class>com.erp.common.SetEncodeFilter</filter-class>
所指路径增加SetEncodeFilter类,这个类可以参考tomcat的一个SetEncodeFilter类,考过来就可以用了。
useUnicode=true&characterEncoding=gb2312
刚做jsp的人都是这样的
哈哈
你的方法能不能具体点,我这么理解试过了,好像不行,
你是说这么用吗 ?
String strInfoTitle 是插入表前的字段值
也就是说 strInfoTitle 这个值我已经得到了,但是现在要用下面的方法处理一下,
不过结果不理想
strInfoTitle = new String(strInfoTitle.getBytes("GB2312"));
----------------------------------
to BigHill(山河水):
你说的这个方法中,那个tomcat的一个SetEncodeFilter类我怎么没有找到啊 ?
能不能告诉我在哪里能找到?给分没有问题,我可以另开一个帖子给分!----------------------------------
to all :感谢大家把我的问题顶上去,来者皆有分哟 !
这个问题如果可以顺利解决,我会总结整理出来,方便以后类似问题的解决!
/**
* 转成ISO-8859-1编码
* @param str
* @return
*/
public static String encode(String str) {
String s;
try {
String tempStr = str;
byte tempByte[] = tempStr.getBytes("ISO8859-1");
String temp = new String(tempByte);
String s1 = temp;
return s1;
}
catch (Exception e) {
s = "";
}
return s;
}
你给不给分啊?
建议,以后说散分但不结贴的麻烦版主封ID