img
.
Figure 17-7. The contact list view in the Chinese (HK) language
Because we defined localeResolver in the DispatcherServlet's WebApplicationContext, Spring MVC
will store the locale setting in your browser's cookie (with the name locale), and by default, the cookie
will be kept for the user session. If you want to persist the cookie for a longer time, in the localeResolver
bean definition in Listing 17-13, you can override the property cookieMaxAge, which is inherited from the
class org.springframework.web.util.CookieGenerator.
To switch to English (US), you can append the URL in your browser with ?lang=en_US, and the page
will switch back to English (US). Although we don't provide the properties file named
application_en_US.properties, Spring MVC will fall back to use the file application.properties, which
stores the properties in default language of English.
Theming and Templating
Besides i18n, a web application requires an appropriate look and feel (for example, a business web site
needs a professional look and feel, while a social web site needs a more vivid style), as well as a
consistent layout so that users will not get confused while using the web application.
In a web application, the styles should be externalized in style sheets, instead of hard-coded into the
view page. In addition, the style names should be consistent so that various "themes" can be prepared
by simply switching the style sheet file. Spring MVC provides comprehensive support for the theming of
web applications.
In addition, in order to provide a consistent layout, a templating framework is required. In this
section, we will use Apache Tiles (http://tiles.apache.org), a popular page templating framework, for
view templating support. Spring MVC tightly integrates with Apache Tiles in this aspect.
In the following sections, we will discuss how to enable theming support in Spring MVC, as well as
how to use Apache Tiles to define our page layout.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home