2011-01-30 53 views
1

我正在开发struts 2和spring web应用程序,它支持两种语言:英语和印地语。 我已配置国际化,但它不起作用,即当我从浏览器更改编码时,文本不会更改。 我试图甚至programitically更改语言环境,但它仍然无法正常工作struts 2国际化不起作用

RegisterAction.java

public class RegisterAction extends ActionSupport { 

public String execute(){ 
    return "SUCCESS"; 
} 

public Locale getLocale(){ 
    return new Locale("hi"); 
} 
    } 

struts.xml的

<action name="register" class="com.medics.action.RegisterAction"> 
    <result name="SUCCESS">/Register.jsp</result> 
</action> 

Register.jsp

<%@ taglib prefix="s" uri="/struts-tags" %> 
<h4><s:text name="Registration"/></h4> 

global-messages.properties

hello=hello 
Registration=Registration 

global-messages_hi.properties

Registration=\\u2354\\u2379\\u327\\u2367\\u2344\\u2381 

这里是项目

struts.xml中的快照和两个消息文件在classpath的根目录

回答

1

不幸的是,您将您的密钥命名为与英文中的值相同,因此您无法确定英文包是否正确加载。我的第一个猜测是Struts不知道全局消息* .properties是语言包。

尝试增加了此信息的struts.xml:

<constant name="struts.custom.i18n.resources" value="global-messages"/> 

编辑

如果您确信英国捆装,那么你要调试的应用程序以确认印地文语言环境正在由Struts2正确设置。您的行动中的断点应允许您轻松检查getLocale()的值。

+0

我已经在struts.properties文件中定义了全局消息解析包,因为当我更改该包中的值时,它已反映在网页上 – 2011-02-01 14:07:37