Working to migrate an application from Struts 1.2.x to Spring MVC, I am stuck at a place where in JSP I have to use labels from .properties lookup files.
In the legacy code, the app has used Struts' MessageTag and a custom tag using TagUtils.message() from Struts to specify the bundle name from where the value of a given key needs to fetched from.
Now with migration to Spring, I have defined all the lookup file bundles in SpringContext.xml like so:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB-INF/lookups/abc</value>
<value>/WEB-INF/lookups/xyz</value>
...
</list>
</property>
</bean>
Using spring:message tag with the key as code worked flawlessly up until I reached a point where 2 lookup bundles use the same keys but have different value. Ideally, I would just rename the keys to be unique but that is not feasible given the code change that entails.
I am wondering if there is a way to specify the bundle name somehow so that in a case of ambiguous keys, Spring knows which bundle to fetch the values from.
I thought of extending either MessageSource or ReloadableResourceBundleMessageSource to a custom class and implement a method that provide a functionality that I am looking for but I basically hit a dead end without any documentation or example of such an implementation.