You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Perssy Llamosas <pl...@telecall.com.pe> on 2007/07/09 23:53:42 UTC

Struts 2.x mapping question

Hello,

I am trying to configure my struts application to listen to request 
without .action or .do
I think it has to do something with the struts.mapper.class but I cannot 
seem to make it work, I have tried several approaches but I cannot get 
rid of the .action or .do without mapping everything to struts which 
would get rid of the static content.

My current configuration:
web.xml
...
<filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping>
...


struts.xml
<struts>
    <constant name="struts.enable.SlashesInActionNames" value="true"/>
    <constant name="struts.mapper.class" 
value="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper"/>
    <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>

    <package name="default" extends="struts-default">
        <action name="search" class="org.beyond.SearchAction">
            <result name="success">/pages/result.jsp</result>
        </action>
    </package>
</struts>

I want to access to the page as http://localhost:8080/directory/search
I currently access with http://localhost:8080/directory/search.action

Thanks.

Perssy Llamosas.

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


Re: Struts 2.x mapping question

Posted by Nova Yu <ne...@gmail.com>.
but it's struts1.X not struts2.x

2007/7/11, Perssy Llamosas <pl...@telecall.com.pe>:
>
> This article answers my question:
>
> http://www.lunatech-research.com/archives/2005/07/29/struts-urls
>
> There is a big but, mapping each extension in the web.xml to the default
> servlet works but it's not the ideal solution since it would require
> that every extension in my application to be mapped, what about the
> extension less files?. The result would be quite complicated and I am
> trying to make things easier and fast with struts 2.x. Isn't there any
> other way? Perhaps writing a custom mapper or filter?
>
> Perssy Llamosas
>
> Perssy Llamosas wrote:
> > Yes, I tried setting that constant but that makes every static file
> > not to be served by tomcat.
> > with:
> > 'struts.action.extension='
> > there won't be .css .html .js
> >
> > There must be another way. I have seen examples of custom mappers
> > without .action but I don't seem to be able to make them work in
> > struts 2.x
> >
> > Perssy Llamosas
> >
> > Don Brown wrote:
> >> You'll need to tell Struts to not use an action extension.  I believe
> >> the setting is 'struts.action.extension=', so by setting it to
> >> nothing, it now won't require the '.action' extension.  You shouldn't
> >> need to use the restful2 action mapper for this to work.  Be warned,
> >> it may not be fully compatible with all the tags.
> >>
> >> Don
> >>
> >> On 7/10/07, yitzle <yi...@users.sourceforge.net> wrote:
> >>> I found this via Google
> >>>
> >>>
> http://struts.apache.org/2.0.8/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.html
> >>>
> >>> > Default action mapper implementation, using the standard *.[ext]
> >>> (where ext usually "action")
> >>> > pattern. The extension is looked up from the Struts configuration
> >>> key struts.action.exection.
> >>>
> >>> HTH
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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
> >>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>


-- 
Netnova.Yu

Re: Struts 2.x mapping question

Posted by Don Brown <do...@gmail.com>.
Yeah, you could map each in web.xml.  A better solution might be to
use prefix-mapping in web.xml, so that all app/ request go to your
Struts 2 app.

Don

On 7/11/07, Perssy Llamosas <pl...@telecall.com.pe> wrote:
> This article answers my question:
>
> http://www.lunatech-research.com/archives/2005/07/29/struts-urls
>
> There is a big but, mapping each extension in the web.xml to the default
> servlet works but it's not the ideal solution since it would require
> that every extension in my application to be mapped, what about the
> extension less files?. The result would be quite complicated and I am
> trying to make things easier and fast with struts 2.x. Isn't there any
> other way? Perhaps writing a custom mapper or filter?
>
> Perssy Llamosas
>
> Perssy Llamosas wrote:
> > Yes, I tried setting that constant but that makes every static file
> > not to be served by tomcat.
> > with:
> > 'struts.action.extension='
> > there won't be .css .html .js
> >
> > There must be another way. I have seen examples of custom mappers
> > without .action but I don't seem to be able to make them work in
> > struts 2.x
> >
> > Perssy Llamosas
> >
> > Don Brown wrote:
> >> You'll need to tell Struts to not use an action extension.  I believe
> >> the setting is 'struts.action.extension=', so by setting it to
> >> nothing, it now won't require the '.action' extension.  You shouldn't
> >> need to use the restful2 action mapper for this to work.  Be warned,
> >> it may not be fully compatible with all the tags.
> >>
> >> Don
> >>
> >> On 7/10/07, yitzle <yi...@users.sourceforge.net> wrote:
> >>> I found this via Google
> >>>
> >>> http://struts.apache.org/2.0.8/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.html
> >>>
> >>> > Default action mapper implementation, using the standard *.[ext]
> >>> (where ext usually "action")
> >>> > pattern. The extension is looked up from the Struts configuration
> >>> key struts.action.exection.
> >>>
> >>> HTH
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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
> >>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: Struts 2.x mapping question

Posted by Perssy Llamosas <pl...@telecall.com.pe>.
This article answers my question:

http://www.lunatech-research.com/archives/2005/07/29/struts-urls

There is a big but, mapping each extension in the web.xml to the default 
servlet works but it's not the ideal solution since it would require 
that every extension in my application to be mapped, what about the 
extension less files?. The result would be quite complicated and I am 
trying to make things easier and fast with struts 2.x. Isn't there any 
other way? Perhaps writing a custom mapper or filter?

Perssy Llamosas

Perssy Llamosas wrote:
> Yes, I tried setting that constant but that makes every static file 
> not to be served by tomcat.
> with:
> 'struts.action.extension='
> there won't be .css .html .js
>
> There must be another way. I have seen examples of custom mappers 
> without .action but I don't seem to be able to make them work in 
> struts 2.x
>
> Perssy Llamosas
>
> Don Brown wrote:
>> You'll need to tell Struts to not use an action extension.  I believe
>> the setting is 'struts.action.extension=', so by setting it to
>> nothing, it now won't require the '.action' extension.  You shouldn't
>> need to use the restful2 action mapper for this to work.  Be warned,
>> it may not be fully compatible with all the tags.
>>
>> Don
>>
>> On 7/10/07, yitzle <yi...@users.sourceforge.net> wrote:
>>> I found this via Google
>>>
>>> http://struts.apache.org/2.0.8/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.html 
>>>
>>> > Default action mapper implementation, using the standard *.[ext] 
>>> (where ext usually "action")
>>> > pattern. The extension is looked up from the Struts configuration 
>>> key struts.action.exection.
>>>
>>> HTH
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> 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


Re: Struts 2.x mapping question

Posted by Perssy Llamosas <pl...@telecall.com.pe>.
Yes, I tried setting that constant but that makes every static file not 
to be served by tomcat.
with:
'struts.action.extension='
there won't be .css .html .js

There must be another way. I have seen examples of custom mappers 
without .action but I don't seem to be able to make them work in struts 2.x

Perssy Llamosas

Don Brown wrote:
> You'll need to tell Struts to not use an action extension.  I believe
> the setting is 'struts.action.extension=', so by setting it to
> nothing, it now won't require the '.action' extension.  You shouldn't
> need to use the restful2 action mapper for this to work.  Be warned,
> it may not be fully compatible with all the tags.
>
> Don
>
> On 7/10/07, yitzle <yi...@users.sourceforge.net> wrote:
>> I found this via Google
>>
>> http://struts.apache.org/2.0.8/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.html 
>>
>> > Default action mapper implementation, using the standard *.[ext] 
>> (where ext usually "action")
>> > pattern. The extension is looked up from the Struts configuration 
>> key struts.action.exection.
>>
>> HTH
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>


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


Re: Struts 2.x mapping question

Posted by Don Brown <do...@gmail.com>.
You'll need to tell Struts to not use an action extension.  I believe
the setting is 'struts.action.extension=', so by setting it to
nothing, it now won't require the '.action' extension.  You shouldn't
need to use the restful2 action mapper for this to work.  Be warned,
it may not be fully compatible with all the tags.

Don

On 7/10/07, yitzle <yi...@users.sourceforge.net> wrote:
> I found this via Google
>
> http://struts.apache.org/2.0.8/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.html
> > Default action mapper implementation, using the standard *.[ext] (where ext usually "action")
> > pattern. The extension is looked up from the Struts configuration key struts.action.exection.
>
> HTH
>
> ---------------------------------------------------------------------
> 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


Re: Struts 2.x mapping question

Posted by yitzle <yi...@users.sourceforge.net>.
I found this via Google

http://struts.apache.org/2.0.8/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.html
> Default action mapper implementation, using the standard *.[ext] (where ext usually "action")
> pattern. The extension is looked up from the Struts configuration key struts.action.exection.

HTH

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