How it works...

WebApplicationContext can also be used to load specific String messages for rendering purposes, Internationalization (i18N), and error messages. There are two types of Spring component responsible for loading message bundles to the container and these are ResourceBundleMessageSource and ReloadableResourceBundleMessageSource. The former, one of the oldest Spring APIs, contains synchronized helper methods while the latter is the current implementation that contains advanced features such as caching.

Just like InternalResourceViewResolver, MessageSource beans are automatically defined by DispatcherServlet searching it through the bean id messageSource. So if the bean id is different, the message bundle will never be retrieved by <spring:bind>, which will give you an error:

javax.servlet.jsp.JspTagException: No message found under code 'title' for locale 'en_US' 

The entire message bundle is stored in a property file and each entry is a code/message pair where the code is the typical key used to fetch its corresponding message. Some message values are simple String but some might look like our content_header:

content_header=Goodbye! {0}. Last of Chapter {1} 

Here {0} and {1} are called placeholders. Placeholders are expressions that wait for an argument at runtime through the argument attribute of <spring:bind>.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.79.84