You actually can do that with the default mapper, using wildcarding.

Here's an example of what we do :

<action name="view/*"
class="com.thestreet.cms.web.actions.story.ViewAction">
        <param name="id">{1}</param>
</action>

The only trick is that you have to remember to suffix your url appropriately
when calling so that S2's dispatchfilter is able to run and pick up on the
url mapping.

i.e. ( our struts.action.extension is 'page' ) :

http://mysite.com/view/23.page

calls the execute method of the ViewAction and sets 23 to the ID.

Multiple mappings are allowed as well :

<action name="view/*/*"
class="com.thestreet.cms.web.actions.story.ViewAction">
        <param name="category">{1}</param>
        <param name="id">{2}</param>
</action>

to execute :

http://mysite.com/view/movies/16.page

Of course, this implies that for every distinct format of urls that you may
have, you need a mapping set up.  If you have a lot of variety, this could
be problematic.

Otherwise, like Dave mentioned, you can look into using RestfulActionMapper.

I haven't really used Restful (more experience with Restful2) much, but it
seems that it imposes a constraint on you of having your urls of the fashion
:

http://mysite.com/myaction/paramName/paramValue 
 or
http://mysite.com/myaction/myid  ( shortcut ).

If you only have one parameter, or if you don't mind your urls in that
format, it could work for you.

One final comment.  I'm not sure how the default setup is anymore, but my
configuration has 'struts.enable.SlashesInActionNames' to be 'true'.  If you
have trouble with the above ( assuming you try it ), you might want to check
to see if that config param is the same.

hth,
-a


Dave Newton-4 wrote:
> 
> --- meeboo <[EMAIL PROTECTED]> wrote:
>> Is it possible to snap up URL parameters via
>> wildcards in Struts.xml and then pass them on as 
>> request parameters to an action? 
> 
> You may be able to use the RestfulActionMapper to do
> this; I don't know if you can do that with the default
> mapper.
> 
> http://struts.apache.org/2.x/docs/restfulactionmapper.html
> 
> d.
> 
> 
> 
>  
> ____________________________________________________________________________________
> The fish are biting. 
> Get more visitors on your site using Yahoo! Search Marketing.
> http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-URL-mapping-tf3531174.html#a9859852
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to