Expert Spring MVC and Web Flow

(Dana P.) #1

Listing 5-9.Setting alwaysUseFullPath to True


<bean
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">




<bean name="/app/home"
class="com.apress.expertspringmvc.flight.web.HomeController">




Multiple Mappings per Handler
You may also assign multiple mappings to a single handler. Simply separate each mapping
with one or more spaces inside the bean name attribute, as shown in Listing 5-10.


Listing 5-10.Multiple Mappings for a Single Handler


<bean name="/home /homepage /index"
class="com.apress.expertspringmvc.flight.web.HomeController">




Because wildcards are supported, the example shown in Listing 5-10 could be shortened
to Listing 5-11.


Listing 5-11.Multiple Mappings with Wildcards


<bean name="/home* /index"
class="com.apress.expertspringmvc.flight.web.HomeController">




■Tip This convenient mapping technique is useful with MultiActionControllers,which are controllers
that handle multiple URIs with separate methods. For more information, see the section “MultiActionCon-
trollers” in Chapter 6.


Default Mapping
It is also possible to set a default handler, in the case that no other mapping can satisfy the
request. If you wish to designate a default handler, simply map that handler with /*, as shown
in Listing 5-12.


CHAPTER 5 ■THE PROCESSING PIPELINE 89
Free download pdf