环境:eclipse
MessageResources.properties 文件中有
errors.user.name=用户名不能为空通过如下命令进行了编码转换:
native2ascii -encoding gbk MessageResources.properties MessageResources_cn.properties也配置了struts配置文件:
<message-resources parameter="MessageResources_cn"/>但是下面是的页面却显示的是???????
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
<title></title>
</head>
<body>
<bean:message key="errors.user.name"/>
</body>
</html:html>请问一下这个该怎么解决呀?
如何才能正确的配置中文资源文件呀》

解决方案 »

  1.   

    浏览器你换个编码看看 
    我觉得你这样是对的啊我是通过如下命令进行了编码转换:
    native2ascii  MessageResources.properties MessageResources_zh.properties也配置了struts配置文件:
    <message-resources parameter="MessageResources_zh"/>浏览器换成utf8的就显示正确了 unix环境下啊
      

  2.   

    资源文件里的中文不能是中文的,应该是Unicode码
    例如"你好"是"\u4f60\u597d"
    可以在cmd环境下输入native2ascii回车,然后输入中文,屏幕会给你转换的Unicode编码。
    另外可以去找一个叫做PropertiesEditor的Eclipse插件,可以直接在properties里写中文,自动转换Unicode。