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

Struts 乱码主要有三个问题:

Eclipse东西下开发处理Struts 乱码的问题(eclipse项目出现乱码)  struts 乱码 Eclipse工具 第1张

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
转载请说明出处
知优网 » Eclipse东西下开发处理Struts 乱码的问题(eclipse项目出现乱码)

发表评论

您需要后才能发表评论