Java Reference
In-Depth Information
Action Bean Class
Default URL Binding
a.web.users.UserActionBean
/users/User.action
a.b.UserAction
/a/b/User.action
www.a.b.UserBean
/a/b/User.action
web.a.actions.User
/a/actions/User.action
theweb.ActionBeanImpl
/theweb/ActionBeanImpl.action
a.b.stripes.ActionBean
/.action
Figure 2.4: URL binding examples
This mechanism is called URL binding. When a request arrives, Stripes
looks at the URL and searches for the corresponding action bean in the
mapping that was constructed during the binding process.
In Figure 2.4 , we can see a few more examples of action bean class
names and their corresponding URL bindings.
If you're not happy with default URL binding pattern, don't fret. We'll
see how it can be changed in Section 13.2 , Customizing URL Bindings,
on page 283 .
Using the href Attribute
When creating a link with <s:link>, we connected the link to an action
bean by indicating the fully qualified class name of the action bean in
the tag's beanclass= attribute:
<s:link beanclass="stripesbook.action.HelloActionBean"
event="randomDate">
Show a random date and time
</s:link>
We can also use URL bindings directly, such as /Hello.action , with the
href= attribute. In this case, we would have created the link like this:
<s:link href="/Hello.action" event="randomDate">
Show a random date and time
</s:link>
Notice that we did not need to put the context path at the beginning of
the URL. The href= attribute of the <s:link> tag automatically does this
for us. In most cases, using the beanclass= attribute is preferable:
• It clearly states which action bean is the target.
• It makes your code independent of URL binding details.
 
 
 
Search WWH ::




Custom Search