Posted on 2011-05-23 15:54
landor 阅读(1061)
评论(0) 编辑 收藏 所属分类:
编码
最近在生产服务器遇到了个问题,在AIX上发布java web程序,jdk是IBM jdk6_64,用到了struts2.1.6,出现错误
2011-05-23 13:10:51,256 DEBUG [com.opensymphony.xwork2.conversion.impl.XWorkConverter] - global-level type converter for property [createTime] = none found
2011-05-23 13:10:51,256 DEBUG [com.opensymphony.xwork2.conversion.impl.XWorkConverter] - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@354e354e]
2011-05-23 13:10:51,257 DEBUG [com.opensymphony.xwork2.conversion.impl.XWorkConverter] - unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
Could not parse date - Class: java.text.DateFormat
File: DateFormat.java
Method: parse
Line: 348 - java/text/DateFormat.java:348:-1
at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.doConvertToDate(XWorkBasicConverter.java:367)
at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:103)
at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:132)
at com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:296)
at com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:28)
...
Caused by: java.text.ParseException: Unparseable date: "2011-02-23 00:00:00"
at java.text.DateFormat.parse(DateFormat.java:348)
at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.doConvertToDate(XWorkBasicConverter.java:357)
... 81 more
本地和测试服务器都没有问题。
telnet到服务器,执行locale -a,发现缺少中文语言包;安装。
然后再locale -a 发现已经安装;
下面有两种方式修改编码格式;
1 直接修改服务器编码格式为GB18030或者UTF-8(视情况而定);
export LC_ALL=Zh_CN.GB18030
2 到tomcat的bin目录下,修改catalina.sh,在最上面或者某个位置加入:
export LC_ALL=Zh_CN.GB18030
export LANG=$LC_ALL
有个地方需要注意:Zh_CN.GB18030 这几个字符的大小写必须和locale -a中显示的一致;重新启动tomcat,问题解决。