Enoon
Enoon

Reputation: 421

Struts 2 Message Resource look-up issue

I have a webserver with Struts 2.3 (with the conventions plugin)

I'm encountering some problems with the handling of MessageResources for localization. This is my directory layout (simplified):

Package-info.java:

@org.apache.struts2.convention.annotation.ParentPackage(value = "users") 

package it.group.projectName.actions.users;

Now, if I ask for a string contained in global.properties or LoginAction.properties (using <s:text name="navbar.myPage"/> ) everything works fine.

But when I ask for any string contained in package.properties or SampleAction.properties from the page corresponding to SampleAction (sample.jsp) it seems it can't find it and just prints out the key. Any ideas?

According to this article (and others) Struts2 should load those files, but it seems to have some problems with convention plugin and the namespace redefinition.

Upvotes: 1

Views: 1824

Answers (1)

Roman C
Roman C

Reputation: 1

According to that article you should read it careful. Another approach to get message resources is to use getText. Make sure the current locale is default and an action extends ActionSupport.

<s:property value="getText('navbar.myPage')" /> 

Upvotes: 1

Related Questions