You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jordi Rubio Moreno <jr...@grupointercom.com> on 2007/05/15 13:13:08 UTC
[S2] Understanding RestfulActionMapper and Restful2ActionMapper
Hi,
I'm testing HelloWorld struts 2 example with friendly url's. I have read
http://struts.apache.org/2.0.6/docs/restfulactionmapper.html
http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/d
ispatcher/mapper/Restful2ActionMapper.htmlhttp://struts.apache.org/2.0.6
/docs/restfulactionmapper.html
(and a lot of pages found in Google speaking about Restful way)
and I don't understand what I'm doing wrong.
I have declared the HelloWord action as
<action name="HelloWorld/*" class="example.HelloWorld">
<param name="id">{1}</param>
<result>/HelloWorld.jsp</result>
</action>
using wildcards to pass parameters. The HelloWord class has an "id"
member variable, with it's public getters and setters.
The struts.properties has the next lines configurated:
struts.mapper.class=org.apache.struts2.dispatcher.mapper.Restful2ActionM
apper
struts.action.extension=action
struts.enable.DynamicMethodInvocation = false
struts.enable.SlashesInActionNames = true
(I have tested with RestfulActionMapper and DefaultActionMapper objects
too)
I have read all documentation sections that speak about URL syntax
(http://HOST/ACTION_NAME/PARAM_NAME1/PARAM_VALUE1/PARAM_NAME2/PARAM_VALU
E2, etc etc), but my example doesn't works. I have tried this
combinations:
http://localhost:8080/example/HelloWord.action/1
http://localhost:8080/example/HelloWord.action/id/1
http://localhost:8080/example/id/1/HelloWord.action
http://localhost:8080/example/1/HelloWord.action
always with the same result: There is no Action mapped for action name
blablabla/blablabla
Please, I need to understand what I'm doing wrong, because I believe I'm
doing the things as tutorials and articles show, but without right
results...
Thanks a lot!
Jordi Rubio Moreno
RE: Re: [S2] Understanding RestfulActionMapper and Restful2ActionMapper
Posted by Jordi Rubio Moreno <jr...@grupointercom.com>.
Hi Laurie,
Finally I'm working with DefaultActionMapper and wildcards:
Struts.properties:
struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMa
pper
struts.xml
<action name="Search/*/*" class="myproject.Search">
<interceptor-ref name="defaultStack"/>
<param name="what">{1}</param>
<param name="where">{2}</param>
<result name="success">/Results.jsp</result>
<result name="error">/Error.jsp</result>
</action>
and my friendly URLs looks like
http://localhost/app/Search/manager/london.action
Best regards!
Jordi Rubio Moreno
-----Mensaje original-----
De: news [mailto:news@sea.gmane.org] En nombre de Laurie Harper
Enviado el: martes, 15 de mayo de 2007 23:05
Para: user@struts.apache.org
Asunto: Re: [S2] Understanding RestfulActionMapper and
Restful2ActionMapper
I haven't used the restful mappers at all, so I'm just guessing, but it
may be that you need to use prefix mapping instead of suffix mapping in
web.xml.
Either way, if you are going to use suffix mapping, the suffix would
always be the last thing in the URL (not including any query part that
is). You could try these posibilities:
http://localhost:8080/example/HelloWord/1.action
http://localhost:8080/example/HelloWord/id/1.action
but I would think if you want restful URLs, switching to prefix mapping
and getting rid of the .action suffix would be what you want anyway...
L.
Jordi Rubio Moreno wrote:
> Hi,
>
> I'm testing HelloWorld struts 2 example with friendly url's. I have
> read
>
> http://struts.apache.org/2.0.6/docs/restfulactionmapper.html
> http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2
> /d
> ispatcher/mapper/Restful2ActionMapper.htmlhttp://struts.apache.org/2.0
> .6
> /docs/restfulactionmapper.html
> (and a lot of pages found in Google speaking about Restful way)
>
> and I don't understand what I'm doing wrong.
>
> I have declared the HelloWord action as
>
> <action name="HelloWorld/*" class="example.HelloWorld">
> <param name="id">{1}</param>
> <result>/HelloWorld.jsp</result>
> </action>
>
> using wildcards to pass parameters. The HelloWord class has an "id"
> member variable, with it's public getters and setters.
>
> The struts.properties has the next lines configurated:
>
>
> struts.mapper.class=org.apache.struts2.dispatcher.mapper.Restful2Actio
> nM
> apper
> struts.action.extension=action
> struts.enable.DynamicMethodInvocation = false
> struts.enable.SlashesInActionNames = true
>
> (I have tested with RestfulActionMapper and DefaultActionMapper
> objects
> too)
>
> I have read all documentation sections that speak about URL syntax
> (http://HOST/ACTION_NAME/PARAM_NAME1/PARAM_VALUE1/PARAM_NAME2/PARAM_VA
> LU E2, etc etc), but my example doesn't works. I have tried this
> combinations:
>
>
> http://localhost:8080/example/HelloWord.action/1
>
> http://localhost:8080/example/HelloWord.action/id/1
>
> http://localhost:8080/example/id/1/HelloWord.action
>
> http://localhost:8080/example/1/HelloWord.action
>
>
> always with the same result: There is no Action mapped for action name
> blablabla/blablabla
>
> Please, I need to understand what I'm doing wrong, because I believe
> I'm doing the things as tutorials and articles show, but without right
> results...
>
> Thanks a lot!
>
> Jordi Rubio Moreno
>
>
>
---------------------------------------------------------------------
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: [S2] Understanding RestfulActionMapper and Restful2ActionMapper
Posted by Laurie Harper <la...@holoweb.net>.
I haven't used the restful mappers at all, so I'm just guessing, but it
may be that you need to use prefix mapping instead of suffix mapping in
web.xml.
Either way, if you are going to use suffix mapping, the suffix would
always be the last thing in the URL (not including any query part that
is). You could try these posibilities:
http://localhost:8080/example/HelloWord/1.action
http://localhost:8080/example/HelloWord/id/1.action
but I would think if you want restful URLs, switching to prefix mapping
and getting rid of the .action suffix would be what you want anyway...
L.
Jordi Rubio Moreno wrote:
> Hi,
>
> I'm testing HelloWorld struts 2 example with friendly url's. I have read
>
> http://struts.apache.org/2.0.6/docs/restfulactionmapper.html
> http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/d
> ispatcher/mapper/Restful2ActionMapper.htmlhttp://struts.apache.org/2.0.6
> /docs/restfulactionmapper.html
> (and a lot of pages found in Google speaking about Restful way)
>
> and I don't understand what I'm doing wrong.
>
> I have declared the HelloWord action as
>
> <action name="HelloWorld/*" class="example.HelloWorld">
> <param name="id">{1}</param>
> <result>/HelloWorld.jsp</result>
> </action>
>
> using wildcards to pass parameters. The HelloWord class has an "id"
> member variable, with it's public getters and setters.
>
> The struts.properties has the next lines configurated:
>
>
> struts.mapper.class=org.apache.struts2.dispatcher.mapper.Restful2ActionM
> apper
> struts.action.extension=action
> struts.enable.DynamicMethodInvocation = false
> struts.enable.SlashesInActionNames = true
>
> (I have tested with RestfulActionMapper and DefaultActionMapper objects
> too)
>
> I have read all documentation sections that speak about URL syntax
> (http://HOST/ACTION_NAME/PARAM_NAME1/PARAM_VALUE1/PARAM_NAME2/PARAM_VALU
> E2, etc etc), but my example doesn't works. I have tried this
> combinations:
>
>
> http://localhost:8080/example/HelloWord.action/1
>
> http://localhost:8080/example/HelloWord.action/id/1
>
> http://localhost:8080/example/id/1/HelloWord.action
>
> http://localhost:8080/example/1/HelloWord.action
>
>
> always with the same result: There is no Action mapped for action name
> blablabla/blablabla
>
> Please, I need to understand what I'm doing wrong, because I believe I'm
> doing the things as tutorials and articles show, but without right
> results...
>
> Thanks a lot!
>
> Jordi Rubio Moreno
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org