开发者

struts 2 internationalization not working

I am developing struts 2 and spring web applicat开发者_Python百科ion which suppoerts two languages: english and hindi. I have configured internationalization but it is not working i.e. when I change the encoding from browser, the text does not change. I have tried to even change the locale programitically but it still does not work

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

here is the snapshot of the project

struts.xml and the two messages files are in the root of the classpath


Unfortunately, you named your keys the same as your values in English, so you can't really tell if the English bundle is being loaded properly either. My first guess is that Struts does not know that global-messages*.properties are language bundles.

Try adding this to your struts.xml:

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

Edit

If you are sure that the English bundle is loading, then you'll want to debug the application to confirm that the Hindi locale is being set properly by Struts2. A breakpoint in your action should allow you to easily check the value of getLocale().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜