You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mraible <ma...@raibledesigns.com> on 2007/08/16 00:25:50 UTC
Re: Using the Restful2ActionMapper
I'm trying to change from using the old-style URLs to Restful2ActionMapper.
Here's what I've added to struts.xml:
<bean name="struts2"
type="org.apache.struts2.dispatcher.mapper.ActionMapper"
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper"/>
<constant name="struts.mapper.composite"
value="org.apache.struts2.dispatcher.mapper.DefaultActionMapper,org.apache.struts2.dispatcher.mapper.Restful2ActionMapper"/>
I have a UserAction that does CRUD (below).
And the following action definitions:
<!-- List of Users -->
<action name="users" class="userAction" method="list">
<result name="success">userList.jsp</result>
<result name="input">userList.jsp</result>
</action>
<!-- Edit User -->
<action name="editUser" class="userAction" method="edit">
<result name="success">userForm.jsp</result>
<result name="input">userList.jsp</result>
</action>
<!-- Save User -->
<action name="saveUser" class="userAction">
<result name="cancel" type="redirect">users.html</result>
<result name="delete" type="redirect">users.html</result>
<result name="input">userForm.jsp</result>
<result name="success"
type="chain">saveUserWithValidation</result>
</action>
<action name="saveUserWithValidation" class="userAction"
method="save">
<result name="input">userForm.jsp</result>
<result name="success" type="redirect">users.html</result>
</action>
Is it possible to change to something like the following?
<action name="user/*" className="userAction">
{0}
...
</action>
If so, I'm guessing I need to change some method names (i.e. the default
method for /user would be index, so I should change list() to index()) and
some result names (edit goes to "edit", save goes to "save", index goes to
"success")?
Thanks,
Matt
Philip Lorenz-2 wrote:
>
>
>>
>> Tomorrow's task for me is trying RESTful, so hopefully
>> you'll figure this out ;)
>>
>> Do you need the ".action" in the URL?!
>>
>> d.
>
> You can remove the action postfix by setting struts.action.extension to an
> empty string. I just left it enabled to have a clean default config with
> only the neccesary settings changed.
>
> Philip
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Using-the-Restful2ActionMapper-tf3173361.html#a12171692
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Using the Restful2ActionMapper
Posted by Dale Newfield <Da...@Newfield.org>.
mraible wrote:
> I'm trying to change from using the old-style URLs to Restful2ActionMapper.
What do you want your URLs to be for the various actions?
If you really just want the view to look restful, you don't need to muck
with the ActionMapper at all:
/user/bob.html to view bob
<package name="viewUser" namespace="/user" extends="struts-default">
<action name="*" class="userAction" method="view">
<param name="username">{1}</param>
<result name="success">/WEB-INF/pages/viewUser.jsp</result>
<result name="badID">/404.jsp</result>
</action>
</package>
Presumably if you set slashesInActions you can do this without a
separate package.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org