  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | -none- | -none- 2007-08-15 - By mraible
Back
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 (See http://enz-2.ora-code.com) 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@(protected) > For additional commands, e-mail: user-help@(protected) > > >
-- 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@(protected) For additional commands, e-mail: user-help@(protected)
|
|
 |