I have couple of servlets designed to hold its own message source, but there is a single static function which uses this message source as backup and in normal case uses a global BDB to retrieve localized text.
I wanted to know if there is a way to retrieve the MessageSource for the context of the servlet which is calling this global static function ?
I can not use MessageSourceAware in all the servlets. I have looked into the Spring documentation and found MessageSourceAware and @autowired properties. I can not use the annotation because i am using spring 2.0.
Any help appreciated.
Thanks, Parth
If your MessageSource is defined within your WebApplicationContext, you can retrieve it via:
WebApplicationContext webAppContext = RequestContextUtils.getWebApplicationContext(request);
MessageSource messageSource = webAppContext.getBean("messageSource");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With