You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric Lentz <er...@outfastsource.com> on 2012/03/23 19:15:01 UTC

Action mapping - match on anything

Anyone know of a way, in Struts 2, to assign an action that matches on
anything in the URL, including slashes? This would be a catch-all, if no
other action specification is more specific.

I configured:
<constant name="struts.enable.SlashesInActionNames" value="true" />
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.action.extension" value=""/>

If I have <action name="*" ...
then it will match on http://server/context/foo
but it will not match on http://server/context/foo/bar

I could do something like this <action name="*/*" ...
but then I'd need to do that for every combination, and I want to be able
to have n slashes; as is needed (which will vary).

I tried regex, but that requires that I have some kind of {foo} notation
for it to execute a regex. Maybe there's still a way to make that work, but
my imagination has run out on possibilities. OGNL does a bunch of
complaining if the string supplied in the URL doesn't match what's in the
parens in some way.

I see [1] talks about a "catch-all" mapping, as specified above, but again,
no joy on the slashes.

[1] http://struts.apache.org/2.0.11.1/docs/action-configuration.html

Re: Action mapping - match on anything

Posted by Eric Lentz <er...@outfastsource.com>.
Looks like it will! How did I manage to miss that? It was right there on
the same page I referred to! Thanks Paweł!

On Fri, Mar 23, 2012 at 4:20 PM, Paweł Wielgus <po...@gmail.com> wrote:

> Hi Eric,
> maybe this will help:
>
>        <default-action-ref name="cover"></default-action-ref>
>
> Best regards,
> Paweł Wielgus.
>
>
>

Re: Action mapping - match on anything

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Eric,
maybe this will help:

	<default-action-ref name="cover"></default-action-ref>

Best regards,
Paweł Wielgus.


2012/3/23 Eric Lentz <er...@outfastsource.com>:
> Anyone know of a way, in Struts 2, to assign an action that matches on
> anything in the URL, including slashes? This would be a catch-all, if no
> other action specification is more specific.
>
> I configured:
> <constant name="struts.enable.SlashesInActionNames" value="true" />
> <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
> <constant name="struts.action.extension" value=""/>
>
> If I have <action name="*" ...
> then it will match on http://server/context/foo
> but it will not match on http://server/context/foo/bar
>
> I could do something like this <action name="*/*" ...
> but then I'd need to do that for every combination, and I want to be able
> to have n slashes; as is needed (which will vary).
>
> I tried regex, but that requires that I have some kind of {foo} notation
> for it to execute a regex. Maybe there's still a way to make that work, but
> my imagination has run out on possibilities. OGNL does a bunch of
> complaining if the string supplied in the URL doesn't match what's in the
> parens in some way.
>
> I see [1] talks about a "catch-all" mapping, as specified above, but again,
> no joy on the slashes.
>
> [1] http://struts.apache.org/2.0.11.1/docs/action-configuration.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org