Java Reference
In-Depth Information
When changing URL bindings, always make sure they still correspond
to the configured mapping in web.xml . If they do not, Stripes is out of
the picture, and all bets are off!
Changing the .action Extension
Say we are developing the webmail application for A Beautiful Com-
pany, Inc. The owners are so proud of the company name that they
want you to use the . abc extension for all URLs in the application. Our
task consists of changing the default suffix that Stripes uses, . action ,
to . abc .
How much time do we need to do this? A couple of weeks? A couple of
days? An hour?
Well, we can scratch our heads, look troubled, sigh, and tell our boss
that we'll try to get it done within a week. The truth is that it won't take
us more than a few minutes. All we need to do is change the mapping
of the dispatcher servlet in the web.xml file:
Download email_30/web/WEB-INF/web.xml
<servlet-mapping>
<servlet-name> DispatcherServlet </servlet-name>
<url-pattern> * .abc </url-pattern>
</servlet-mapping>
and override the getBindingSuffix ( ) method of NameBasedActionResolver :
Download email_30/src/stripesbook/ext/MyActionResolver.java
package stripesbook.ext;
public class MyActionResolver extends NameBasedActionResolver {
@Override
protected String getBindingSuffix() {
return ".abc";
}
}
That's it, we've completed the task. The whole application now proudly
uses the . abc suffix in its URLs. Let's go ahead and get the bonus points
from our boss for finishing way before the deadline.
Changing the Package Prefixes and Action Bean Suffixes
NameBasedActionResolver has two other protected methods that we can
override to further customize URL binding. Remember that when bind-
ing an action bean to a URL, the package name up to and including any
of action , stripes , web , or www is truncated. You can override getBasePa-
ckages ( ) and return a different set of names.
 
 
Search WWH ::




Custom Search