简体   繁体   中英

Loading messages from resource bundle in Struts 2

I want to load resource bundle (I have two: one for selected language and another default) dynamically in JSP and read the content in JSP. I have tried following way but its just hard-coded.

<s:i18n name="resourcebundle_fr">
   <s:text name="fr_message1" />
</s:i18n>

where what I want is instead of resourcebundle_fr , I want it to be dynamic. Also, the same page has included another JSP page which should also pick the messages from the selected language specific resource bundle.

Struts2 tags has support for OGNL. You can use OGNL expressions in the Struts tag's attributes.

<s:i18n name="%{resourceBundle}">
  <s:text name="fr_message1" />
</s:i18n>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM