struts-user mailing list archives

Hi folks,
I've just resolved my issue. My goal is to add struts-restful-plugin to an
struts2 existent app. So i needed to have an url handler
If I request http://localhost:8080/myApp/login.action, it must be resolved
by DefaultActionMapper
If I request http://localhost:8080/myApp/service/client/324, it must be
resolved by org.apache.struts2.rest.
RestActionMapper
So I have in my struts.xml
<constant name="struts.mapper.class"
value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/>
<constant name="struts.mapper.prefixMapping" value="/service:rest,:struts"/>
Where rest is a bean defined in strus-config.xml (restful plugin) and it is
mapped to org.apache.struts2.rest.RestActionMapper
In my struts.properties
struts.action.extension=action,xml,json,,
And that's all. I hope it can help to someone having the same problem.
Thanks for everything.
p.d. I'm using struts2.2.1
Bye
On Tue, Aug 31, 2010 at 5:24 PM, Dale Newfield <dale@newfield.org> wrote:
> On 8/31/10 5:17 PM, Rafael Taboada wrote:
>
>> But I'm having the same problem "HTTP status 404"
>>
>
> So it is failing to find any valid action mapping? What do your logs show?
> This might help you figure out what's going on:
> http://struts.apache.org/2.x/docs/config-browser-plugin.html
>
>
> My struts.xml looks like :
>>
>
> <include file="example.xml"/>
>>
>
> I don't know what's in that file--I'm guessing a package with the namespace
> "/example"? Do you have any packages whose namespace is "/service"?
>
>
> <package name="default" namespace="/" extends="struts-default">
>>
>
> I've not looked into the details of the plugins you said you're using. Do
> any of them provide packages that you need to extend instead of
> struts-default to get their benefits?
>
>
> <result type="redirectAction">
>> <param name="actionName">HelloWorld</param>
>> <param name="namespace">/example</param>
>>
>
> So if you try to access /index.action, does it redirect to
> /example/HellowWorld.action ?
>
>
> And when I try to acces
>> http://localhost:8080/struts221/example/HelloWorld.action, apparently it
>> is driven by restful, because it shows "HTTP status 404" error
>>
>
> Your configuration doesn't specify that this should be mapped by the
> Restful2ActionMapper, so why do you assume this?
>
>
> Maybe i'm missing another config? What am I doing wrong?
>>
>
> I don't know how the Restful2ActionMapper does it's thing. When I looked
> at the two provided Restful action mappers several years ago I found that
> neither really did what I needed, so I ended up writing my own. I've
> actually found that most of what people want when they say they want REST
> style urls can be provided by the default action mapper with wildcards.
> (Also, make sure that you have SlashesInActionNames set appropriately for
> the rest of your config.)
>
> http://struts.apache.org/2.x/docs/restfulactionmapper.html and/or
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.htmlshould
be helpful.
>
> -Dale
>
--
Rafael Taboada
Software Engineer
Cell : +511-992741026
"No creo en el destino pues no me gusta tener la idea de controlar mi vida"