You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by GF <ga...@gmail.com> on 2011/03/01 14:59:21 UTC

Handling wildcard action names with dot.

I configured struts to handle url mapping with no extensions this way

<constant name="struts.action.extension" value=",," />

With this action mapping
        <action name="*" class="myAction" method="myMethod">
                <param name="myId">{1}</param>
            <result type="tiles">myTile</result>
        </action>

I can handle urls like:

/aaa/bbb/ccc
/aaa/bbb/ddd
/aaa/bbb/eee

But i wish to handle this kind of urls too:

/aaa/bbb/fff.xyz
/aaa/bbb/fff.jkw
/aaa/bbb/fff.anykindofextension

But when i insert a DOT in the action name (mapped by a wildcard) I
get a 404 error.


Any idea?

Thank you

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


Re: Handling wildcard action names with dot.

Posted by st...@gmail.com.
I haven't looked at this for some time, but open up DefaultActionMapper and
have a look.  You can always substitute your own implementation if the
outta-the-box is not what you are looking for.

Peace,
Scott

On Tue, Mar 1, 2011 at 7:59 AM, GF <ga...@gmail.com> wrote:

> I configured struts to handle url mapping with no extensions this way
>
> <constant name="struts.action.extension" value=",," />
>
> With this action mapping
>        <action name="*" class="myAction" method="myMethod">
>                <param name="myId">{1}</param>
>            <result type="tiles">myTile</result>
>        </action>
>
> I can handle urls like:
>
> /aaa/bbb/ccc
> /aaa/bbb/ddd
> /aaa/bbb/eee
>
> But i wish to handle this kind of urls too:
>
> /aaa/bbb/fff.xyz
> /aaa/bbb/fff.jkw
> /aaa/bbb/fff.anykindofextension
>
> But when i insert a DOT in the action name (mapped by a wildcard) I
> get a 404 error.
>
>
> Any idea?
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Handling wildcard action names with dot.

Posted by Maurizio Cucchiara <ma...@gmail.com>.
I'm afraid that you should consider to use apache mod_rewrite or
something like an url rewrite filter [1]?

[1] http://www.tuckey.org/urlrewrite/

On 1 March 2011 18:24, Chris Pratt <th...@gmail.com> wrote:
> It's possible you might have to play with your filter entries in web.xml
> also.  The container also maps by extension.
>  (*Chris*)
>
> On Tue, Mar 1, 2011 at 5:59 AM, GF <ga...@gmail.com> wrote:
>
>> I configured struts to handle url mapping with no extensions this way
>>
>> <constant name="struts.action.extension" value=",," />
>>
>> With this action mapping
>>        <action name="*" class="myAction" method="myMethod">
>>                <param name="myId">{1}</param>
>>            <result type="tiles">myTile</result>
>>        </action>
>>
>> I can handle urls like:
>>
>> /aaa/bbb/ccc
>> /aaa/bbb/ddd
>> /aaa/bbb/eee
>>
>> But i wish to handle this kind of urls too:
>>
>> /aaa/bbb/fff.xyz
>> /aaa/bbb/fff.jkw
>> /aaa/bbb/fff.anykindofextension
>>
>> But when i insert a DOT in the action name (mapped by a wildcard) I
>> get a 404 error.
>>
>>
>> Any idea?
>>
>> Thank you
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>



-- 
Maurizio Cucchiara

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


Re: Handling wildcard action names with dot.

Posted by Chris Pratt <th...@gmail.com>.
It's possible you might have to play with your filter entries in web.xml
also.  The container also maps by extension.
  (*Chris*)

On Tue, Mar 1, 2011 at 5:59 AM, GF <ga...@gmail.com> wrote:

> I configured struts to handle url mapping with no extensions this way
>
> <constant name="struts.action.extension" value=",," />
>
> With this action mapping
>        <action name="*" class="myAction" method="myMethod">
>                <param name="myId">{1}</param>
>            <result type="tiles">myTile</result>
>        </action>
>
> I can handle urls like:
>
> /aaa/bbb/ccc
> /aaa/bbb/ddd
> /aaa/bbb/eee
>
> But i wish to handle this kind of urls too:
>
> /aaa/bbb/fff.xyz
> /aaa/bbb/fff.jkw
> /aaa/bbb/fff.anykindofextension
>
> But when i insert a DOT in the action name (mapped by a wildcard) I
> get a 404 error.
>
>
> Any idea?
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Handling wildcard action names with dot.

Posted by Fred Toth <ft...@synernet.com>.
Coincidentally, I've been working on this same issue. I needed struts 
actions to handle PDFs.

My solution was to add pdf to the action extensions, as in:

<constant name="struts.action.extension" value="pdf," />

Note the critical trailing comma which allows for blank extensions in 
addition to pdf. I'm not sure exactly how struts, by default, knows to 
ignore anything with an extension. Mostly this is a good thing, as it 
allows you to serve images, static resources, etc., without going 
through struts.

There's this interesting comment in the default.properties file inside 
the struts core jar:

### The blank extension allows you to match directory listings as well 
as pure action names
### without interfering with static resources.
struts.action.extension=action,,

Sounds like what you need is to handle ALL urls, with any possible 
extension? I don't know how to do that, but I bet there's a way. Of 
course this would mean that you would have to handle all static 
resources through struts which could be painful. But maybe you don't 
have any.

Thanks,

Fred

On 3/1/2011 8:59 AM, GF wrote:
> I configured struts to handle url mapping with no extensions this way
>
> <constant name="struts.action.extension" value=",," />
>
> With this action mapping
>          <action name="*" class="myAction" method="myMethod">
>                  <param name="myId">{1}</param>
>              <result type="tiles">myTile</result>
>          </action>
>
> I can handle urls like:
>
> /aaa/bbb/ccc
> /aaa/bbb/ddd
> /aaa/bbb/eee
>
> But i wish to handle this kind of urls too:
>
> /aaa/bbb/fff.xyz
> /aaa/bbb/fff.jkw
> /aaa/bbb/fff.anykindofextension
>
> But when i insert a DOT in the action name (mapped by a wildcard) I
> get a 404 error.
>
>
> Any idea?
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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