Struts中properties文件中中文乱码解决方案

首先在http://download.csdn.net/source/2230779下载文件,解压,将得到的文件夹

拷贝到myeclipse中安装目录的plugins目录中,如我的myeclipse安装目录:C:\Program Files\Genuitec\Common\plugins。然后重新启动myeclipse

 

打开**.properties文件:右击 >open with>MyEclispe properties Editor

 

然后点击右侧的Add,在出项的对话框中输入namevalue,点击Finish,及添加完了一条记录。

如输入:

login.error.username=请输入用户名
login.error.userpassword=请输入用户密码

添加完成后、

中文已经被转换为 另一种形式的编码,以source视图查看可见上面的记录变为:

login.error.username=\u8BF7\u8F93\u5165\u7528\u6237\u540D
login.error.userpassword=\u8BF7\u8F93\u5165\u7528\u6237\u5BC6\u7801

不过再在web组件中调用时则不会显示乱码。

如:

if(userpassword.equals(baduserpassword)){

       errors.add("userpassword",new ActionMessage("logon.baduserpassword.error",baduserpassword));

       saveErrors(request,errors);

       return(new ActionForward(mapping.getInput()));

       }

注意:我的Myeclipse>windows>preferences>General>Content Types>Text>Java Properties File中显示的Default encoding ISO-8859-1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值