|
From: Daniel M. <mi...@pa...> - 2004-07-07 03:45:10
|
Hello, I am having problems accessing my message resources when they are loaded with ReloadableResourceBundleMessageSource (RRBMS). When RRBMS is used, the properties files must be located outside the classpath to be reloadable. However, the JSTL <fmt:bundle> tag's "basename" attribute and the <fmt:message> tag's "bundle" attribute only accept a classpath url (e.g. basename="com.example.messages"). It would be nice if they accepted file url's as well (e.g. basename="WEB-INF/jsp/common/messages.properties"), but they don't :( Normally this should not be a problem because Spring puts the message bundle where JSTL can find it when a JSTLView is rendered. However, I want to use message resources in error pages (404, 403, java.lang.Exception, etc.) which are not rendered by Spring. Error pages are configured in web.xml; the Spring context where the message source locations are configured is bypassed when they are rendered. Is there any way to load message resources explicitly inside a jsp page when the properties file is not on the classpath? Could another tag be added to the Spring tag library that would fetch the message bundle(s) from the Srping configuration and/or load the bundle from the file resource? Example usage: <spring:bundle> <!-- - [Reloadable]ResourceBundleMessageSource configured - in the Spring context is used to retrieve messages --> <fmt:message key="some.message.key" /> </spring:bundle> OR <spring:bundle resource="WEB-INF/jsp/common/messages.properties"> <!-- - Message resources are loaded from the location - specified by the "resource" attribute --> <fmt:message key="some.message.key" /> </spring:bundle> Aside: IMHO the "code" attribute of the <spring:message> tag should to be deprecated and changed to match JSTL "key" attribute. That would enable a developer to easily switch from <fmt:message> to <spring:message> without changing attribute name(s)--plus it's less attributes to remember because it's standard...even the Struts <bean:message> tag got that one right. Thanks, Daniel Miller |