自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Eclipse工具下開發(fā)解決Struts 亂碼的問題

開發(fā) 后端
本文將對Eclipse工具下開發(fā)struts亂碼的問題的討論,主要是將要顯示成中文的部分重新編碼。

Struts 亂碼主要有三個問題:

1,struts中資源文件中如果value為中文,顯示struts 亂碼

解決辦法:使用eclipse插件Properties Editor

2,在文本域里輸入中文顯示亂碼

解決辦法:使用servlet過濾器filter

最簡單的可以借用tomcat下面的filters.SetCharacterEncodingFilter在自己的web.xml配置中加入tomcat中servlet_examples相應(yīng)配置(高手可以自己配!)

本人配置如下:

SetCharacterEncoding 

filters.SetCharacterEncodingFilter

encoding

GBK

SetCharacterEncoding

*.do


3,從某些數(shù)據(jù)庫里讀出亂碼

解決辦法:把你要顯示成中文的部分重新編碼

例如:

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中開發(fā)struts應(yīng)用程序
  2. 手把手教你在Eclipse中配置開發(fā)Struts
  3. Eclipse下開發(fā)struts完整解決亂碼問題
  4. Struts相關(guān)背景介紹
  5. 使用Easy Struts for Eclipse開發(fā)Struts
責(zé)任編輯:張燕妮 來源: 百度空間
相關(guān)推薦

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

開發(fā)中文亂碼問題

2009-06-19 11:16:14

java web中文亂碼

2009-09-21 17:10:14

struts Hibe

2010-02-06 16:13:49

Ubuntu Auda

2010-05-25 11:24:34

MySQL 亂碼

2012-06-19 14:35:24

JSPJava亂碼

2010-11-09 17:09:23

SQL Server中

2009-07-08 13:22:48

JVM termina

2009-06-02 15:38:36

eclipse streclipse開發(fā)steclipse str

2009-06-01 15:44:18

2009-07-07 13:42:57

Servlet JSP

2009-11-26 16:30:52

Suse中文亂碼問題

2011-02-24 10:48:51

FireFTP
點贊
收藏

51CTO技術(shù)棧公眾號