Java Reference
In-Depth Information
It doesn't get much cleaner than that. Here's a summary of what
Dynam-
icMappingFilter
does to achieve the magic:
• If the request does not produce an error, then the URL matches an
existing static file. Let the request go through untouched in this
case.
• If the request results in a
404
error (not found), send the request to
the action bean that is bound to the URL. This becomes a regular
Stripes-handled request. If no action bean is found, send along
the
404
error.
• If the request produces any other error, send the error through.
Want to take the
DynamicMappingFilter
out for a spin? We just need to
make a few changes to
web.xml
:
• Remove the
DispatcherServlet
definition.
• Remove the
StripesFilter
and
DispatcherServlet
URL mappings.
• Add the
DynamicMappingFilter
, and map it to
/*
.
With these changes, the core of the
web.xml
file becomes the following:
<filter>
<filter-name>
StripesFilter
</filter-name>
<filter-class>
net.sourceforge.stripes.controller.StripesFilter
</filter-class>
<!-- same init-params as before... -->
</filter>
<filter>
<filter-name>
DynamicMappingFilter
</filter-name>
<filter-class>
net.sourceforge.stripes.controller.DynamicMappingFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>
DynamicMappingFilter
</filter-name>
<url-pattern>
/
*
</url-pattern>
<dispatcher>
REQUEST
</dispatcher>
<dispatcher>
FORWARD
</dispatcher>
<dispatcher>
INCLUDE
</dispatcher>
</filter-mapping>
Search WWH ::
Custom Search