Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Incomplete
-
1.2.4
-
None
-
None
-
Operating System: Windows XP
Platform: PC
-
31817
Description
My platform encoding is gb2312,so when i put chinese words in the resources
file and retrive them in the jsp page,i got the incorrect word.
So I write a new messageresourcefactory and messageresource class which
extends the PropertyMessageResourcesFactory and PropertyMessageResources class
and override the getMessage() method in my new messageresource class like this:
public String getMessage(Locale locale, String key) {
String srcmessage = super.getMessage(locale,key);
String destmessage = null;
try
catch(Exception e)
{ System.out.println("Exception From nickmessageresources"); }
return destmessage;
}
then in the struts-config.xml file i use my new
PropertyMessageResourcesFactory class to load the message resource.And put the
following code "<%@page contentType="text/html;chatset=gb2312"%>" at the
beginnig of each jsp fiel,then i get the chinese word in the resource file
correctly.
I think this encoding problem maybe exist in each non-english country.
I hope in the new version of struts,the default PropertyMessageResources's
getMessage() method should first use the getBytes() method with the ISO-8859-1
charset then use the locale to reconstruct the desire String.