I18n in Struts-menu with Struts 2
I've developed a menu using struts-menu 2.4.3 with Struts 2. It's working ok but I need to take the titles of the menus from a properties file (router-messages.properties). The whole application is internationalized like this. But it just doesn't work with struts-menu. Here is my menu-config.xml file:
<Menu name="mainMenu" title="" >
<Item name="ecfMenu" title="ECFs" roles="FISCO" location="DisconnectedEcfsSearch" />
<Item name="reportsMenu" title="Relatórios" roles="ADMIN" location="AlarmReportSearch"/>
<Item name="fiscoMenu" title="Fisco" roles="ADMIN" location="UpdateFiscoForm"/>
<Item name="alarmMenu" title="Alarmes" roles="ADMIN" location="AlarmNotification"/>
<Item name="userMenu" title="application.header.users" roles="ADMIN" location="UserSearch"/>
<Item name="consoleMenu" title="Console" roles="FISCO" location="ConsoleSearch"/>
</Menu>
Please notice that I'm trying to use a key to my properties file in the item 'userMenu'. All other items work, but not this one.
Here's my jsp:
<menu:useMenuDisplayer permissions="rolesAdapter" name="Velocity"
config=开发者_运维百科"/WEB-INF/tabs.html">
<menu:displayMenu name="mainMenu" />
</menu:useMenuDisplayer>
I searched around and even found a guy with the same question but there was no response for him. =/
Does anybody know how to make struts-menu recognize that I'm using a key to a properties file and not a literal String??
Thanks!
Try this:
For the menu-config.xml:
<Menu name="mainMenu" title="" >
<Item name="userMenu" title="application.header.users" roles="ADMIN" location="UserSearch"/>
</Menu>
For the JSP:
Use this:
<%@ taglib prefix="menu" uri="http://struts-menu.sf.net/tag-el"%>
Instead of this:
<%@ taglib prefix="menu" uri="http://struts-menu.sf.net/tag"%>
Invoking the menu:
<menu:useMenuDisplayer bundle="messages" permissions="rolesAdapter" name="Velocity"
config="/WEB-INF/tabs.html">
<menu:displayMenu name="mainMenu" />
</menu:useMenuDisplayer>
For the bundle="messages" provide the name of your resource bundle.
I hope it works for you!
精彩评论