首先要让jsp能正常显示中文,不然资源文件中是中文在页面还是乱码。在装有MyEclipse的情况下,可以进行如下操作:
Window - Preferences - MyEclipse - Files and Editors - JSP -Encoding 改为Chinsese, National Stardard,这样新建的jsp页面会自动加上 <%@ page language="java" pageEncoding="GB18030"%>,从而可以在页面上正常显示中文。手动修改pageEncoding="GB18030"也是一样的。
然后就是让Struts的资源文件支持中文,这里用到了一个插件:Properties Editor,安装过程如下:
[ INSTALLATION ]
Please choose from the screen of Eclipse with "Help" ->"Software Updates" -> "Update Manager". An 'Update Manager' opens.
In the "Feature Updates" view at the lower left of an 'Update Manager', please carry out the right click of the "Sites to Visit", and create a site bookmark by "New" -> "Site Bookmark...".
- The bookmark to create should input the following "URL" and should push an "Finish" button.
Name: Arbitrary input
URL : http://propedit.sourceforge.jp/eclipse/updates/
Bookmark type: Eclipse update site
If a site bookmark is created, the bookmark created at the bottom of "Feature Updates" will appear.
A click of "jp.gr.java_conf.ussiy.app.propedit.eclipse.feature.PropertiesEditorFeature x.x.x" displays a preview on a right window. Since the button "Install Now" is in around the lower right, please click.
具体用法可以参见 http://propedit.sourceforge.jp/index_en.html
Since an installation wizard starts, please click a "Next" button rapidly.
"You will need to restart the workbench for the changes to take effect. Would you like to restart now?" is displayed. Please reboot Eclipse according to a dialog.
安装成功后资源文件的图标就会变成绿色,资源文件的右键打开菜单多出来一项open with PropertiesEditor,用它打开时就可以直接在里面写入中文了,保存打开后还是中文,比较爽。想看看其他编码的形式就用其他的方式打开就可以了。
还有一个工具就是native2ascii,用法参见下面网址:
http://publib.boulder.ibm.com/html/as400/v4r5/ic2989/info/java/rzaha/javaapi/tooldocs/native2ascii.html
这个对已经写好了资源文件估计来的方便一点吧,一般还是用Properties Editor比较方便。