Java Reference
In-Depth Information
The BeanNameUrlHandlerMapping class does not support wildcards to resolve a request
URL to a bean name. Let's assume you want the UpdatePolicyController to handle two
requests: / and / . With BeanNameUrlHanderMapping , you will
need to configure two <bean /> entries. This is redundant, and configuration can be sim-
plified with Apache Ant-style wildcard path mapping with the SimpleUrlHandlerMapping
class. Since this is not the default handler mapping, it has to be explicitly configured in
the Spring configuration file, as shown in Listing 3-8.
Listing 3-8. insurance-servlet.xml
<bean name="simpleUrlHandlerMapping"
<property name="mappings">
<prop key="/*">updatePolicyController</prop>
<bean name="updatePolicyController" class="com.apress.insuranceapp å
As shown in Listing 3-8, the controllers are configured just like any other bean in the
Spring container. The mappings property of the handler mapping is very important. It is
wired using a java.util.Properties object. Each key of this object is a URL pattern. The
key for the updatePolicyController is the URL pattern: /* . It uses the * wildcard.
This means any request URL ending with will be handled by this page con-
Note that once this handler mapping is detected by the dispatcher servlet, it no
longer needs to create the default bean handler mapping instance.
Search WWH ::

Custom Search