Eclipse工具下开发解决Struts 乱码的问题

开发 后端
本文将对Eclipse工具下开发struts乱码的问题的讨论,主要是将要显示成中文的部分重新编码。

Struts 乱码主要有三个问题:

1,struts中资源文件中如果value为中文,显示struts 乱码

解决办法:使用eclipse插件Properties Editor

2,在文本域里输入中文显示乱码

解决办法:使用servlet过滤器filter

最简单的可以借用tomcat下面的filters.SetCharacterEncodingFilter在自己的web.xml配置中加入tomcat中servlet_examples相应配置(高手可以自己配!)

本人配置如下:

SetCharacterEncoding 

filters.SetCharacterEncodingFilter

encoding

GBK

SetCharacterEncoding

*.do


3,从某些数据库里读出乱码

解决办法:把你要显示成中文的部分重新编码

例如:

while(rs.next())

{

string col1=rs.getString(1);

string col2=rs.getString(2);

string col3=rs.getString(3);

float col4=rs.getFloat(4);

col1=new string(col1.getBytes("iso-8859-1"),"GB2312");

col2=new string(col2.getBytes("iso-8859-1"),"GB2312");

col3=new string(col3.getBytes("iso-8859-1"),"GB2312");

----

}

至此Struts乱码问题得到解决。

【编辑推荐】

  1. 在Eclipse中开发struts应用程序
  2. 手把手教你在Eclipse中配置开发Struts
  3. Eclipse下开发struts完整解决乱码问题
  4. Struts相关背景介绍
  5. 使用Easy Struts for Eclipse开发Struts
责任编辑:张燕妮 来源: 百度空间
相关推荐

2009-06-30 14:02:00

Struts乱码Eclipse

2011-04-25 13:06:38

EclipseLinux

2009-06-04 10:44:18

struts2 乱码解决办法

2009-06-03 16:41:21

Eclipse乱码Eclipse

2010-06-21 13:35:50

JavaJava EE乱码

2011-03-22 16:09:33

MySQL 5.0.1乱码

2011-03-07 14:06:22

FileZilla乱码

2015-04-01 10:26:32

开发中文乱码问题

2009-06-19 11:16:14

java web中文乱码

2010-02-06 16:13:49

Ubuntu Auda

2012-06-19 14:35:24

JSPJava乱码

2010-05-25 11:24:34

MySQL 乱码

2010-11-09 17:09:23

SQL Server中

2009-09-21 17:10:14

struts Hibe

2009-07-08 13:22:48

JVM termina

2009-07-07 18:20:54

JSP页面显示乱码

2009-11-26 16:30:52

Suse中文乱码问题

2009-07-07 13:42:57

Servlet JSP

2011-02-24 10:48:51

FireFTP

2010-11-24 15:22:51

MySQL命令行
点赞
收藏

51CTO技术栈公众号