We’ll cover binding request parameters from forms in the next chapter, so we won’t
jump ahead here and confuse the topic at hand. But we will provide the hint required to
make the file contents transparently show up in your command bean: you must register
either ByteArrayMultipartFileEditoror StringMultipartFileEditorwith your data binder
(for instance, inside the initBinder()method of your form controller). What does that mean?
Hang tight, or skip to Chapter 7.
As long as the contents of the uploaded file aren’t too large, we recommend the direct
property binding because it is less work for you and certainly more transparent.
ThemeResolver
Spring MVC supports a concept of themes, which are interchangeable looks and feels for
your web application. Often called skins, themes are a way to abstract a look and feel (color
scheme, logo, size of buttons, and so on) from the user interface. This is helpful to the user
interface implementer, because the skin information can be rendered at runtime, instead of
simply duplicating each page once for each look and feel. We will cover themes in greater
detail in the Chapter 7. For now, we will focus on how to choose and manipulate themes
for each user’s requests. You will find that the concepts here are very similar to the
LocaleResolver.
Listing 5-43 contains the ThemeResolverinterface.
Listing 5-43.ThemeResolver Interface
package org.springframework.web.servlet;
public interface ThemeResolver {
String resolveThemeName(HttpServletRequest request);
void setThemeName(HttpServletRequest request, HttpServletResponse response,
String themeName);
}
As you can see, the ThemeResolverinterface resembles the LocaleResolverinterface very
closely. One major difference between the two is ThemeResolverreturns strings instead of a
strongly typed objects. The resolution of the theme name to a org.springframework.ui.context.
Themeobject is done via an org.springframework.ui.context.ThemeSourceimplementation.
The ThemeResolverinterface has the same types of implementations as the
LocaleResolverinterface. Out of the box, Spring MVC provides a FixedThemeResolver, a
CookieThemeResolver, and a SessionThemeResolver. Just like their LocaleResolvercounter-
parts, both CookieThemeResolverand SessionThemeResolversupport retrieving and changing
the theme, while FixedThemeResolveronly supports a read-only theme.
112 CHAPTER 5 ■THE PROCESSING PIPELINE