Expert Spring MVC and Web Flow

(Dana P.) #1
public final void setParamMappings(Map<String, Object> paramMappings) {
this.paramMappings.putAll(paramMappings);
}

public final void setParameterName(String parameterName) {
this.parameterName = parameterName;
}

@Override
protected Object getHandlerInternal(HttpServletRequest request)
throws Exception {
String parameterValue = request.getParameter(parameterName);
return paramMappings.get(parameterValue);
}

public void afterPropertiesSet() throws Exception {
Assert.hasText(parameterName,
"parameterName must not be null or blank");
}

}


Because this class extends AbstractHandlerMapping, if no handler exists for the request
parameter, then the AbstractHandlerMappingwill attempt to load the default handler, which
can be set via the XML bean definition. See Listing 5-17.


Listing 5-17.RequestParameterHandlerMapping XML Definition


<bean
class="com.apress.expertspringmvc.chap5.RequestParameterHandlerMapping">











With this configuration, the URL http://example.org/springapp/app?action=loadwould
be routed to the loadController. Remember that /appis just the DispatcherServletmapping
and not specific to any controller or request handler.


CHAPTER 5 ■THE PROCESSING PIPELINE 93
Free download pdf