Java Reference
In-Depth Information
return builder.toString();
}
}
With that in place, MessageListActionBean is bound to the following:
/action/message_list
We now have cleaner default URL bindings. It's a good start, but param-
eters still show up at the end, like this:
/action/message_list?folder=1
To continue the cleanup, we need to use @UrlBinding and embed param-
eters within the URL. To embed a parameter, put its name between { }
within the binding:
Download email_31/src/stripesbook/action/MessageListActionBean.java
@UrlBinding("/action/message_list/{folder}")
public class MessageListActionBean extends BaseActionBean {
The folder parameter now appears as this:
/action/message_list/1
Hello, clean URLs!
But wait, there's more. When we embed a parameter in a URL, we can
optionally specify a default value for the parameter. That value will be
used if the parameter is omitted from the request URL. For example,
the following binding will use a folder parameter with a value of 1 if the
request URL is /action/message_list :
@UrlBinding("/action/message_list/{folder=1}")
public class MessageListActionBean extends BaseActionBean {
Besides parameters, event names can also be embedded in the URL. For
example, ContactListActionBean has the list event to see the contact list,
and it has the view event to view the details of a specific contact. The
special {$event} parameter embeds the event name in the URL binding:
Download email_31/src/stripesbook/action/ContactListActionBean.java
@UrlBinding("/action/contact_list/{$event}/{contact}")
public class ContactListActionBean extends ContactBaseActionBean {
These clean URLs now work with ContactListActionBean :
/action/contact_list/list (contact parameter is not used)
/action/contact_list/view/1 (view the details of contact 1)
 
 
Search WWH ::




Custom Search