If you don't have any other resources ending in .xml .html .etc inside your
webapp you can modify the filter-mapping, if you do then you might have to
consider the idea of a directory in which all objects are mapped to actions
and a separate directory where they are not, e.g.;

http://domain.com/struts2/stuff.html <-- Static HTML
http://domain.com/struts2/dynamic/stuff.html <-- Goes to an action.

Al.

-----Original Message-----
From: Kevin Conroy [mailto:[EMAIL PROTECTED] 
Sent: 24 May 2007 15:51
To: Struts Users Mailing List
Subject: Re: [S2] Results Based on URL File Types

Hi Roger (and Al),
Thanks for your replies.

I had thought about doing something like what you specified Roger, by
passing the return type as a parameter. However, in keeping with what seems
to be fairly standard RESTful web service protocol, I was hoping to have the
return type specified after the query name. Then from the users perspective
the URL file type that the request matches the return type, rather than it
just being some random query.

It's true that I could also build the return type into the URL path, but
that would give me several different actions for each query, and I'd like to
have one Action object that knows how to get all of the POJOs that are
associated with the query and then use the results to mux out how to
serialize the POJOs into the correct format (e.g. REST xml, json, rss, etc.)

So is there any way to tell Struts to ignore the extension (*.do or
*.action) and just assume that all requests into the application (or
namespace) are in fact actions it should execute? I'm suspecting not, as
this might block access to other non-action resources, but if there is some
way to set up a * pattern, that might work too.

Thanks for all of your help.

--
Kevin Conroy
E-mail: [EMAIL PROTECTED]

On 5/24/07, Roger Varley <[EMAIL PROTECTED]> wrote:
>
> I'm still a newbie as well so take this with a pinch of salt. I would 
> try doing it this way;
>
> http://www.domain.com/struts2/queryName?param1=foo,param2=xml
> http://www.domain.com/struts2/queryName?param1=foo,param2=json
> http://www.domain.com/struts2/queryName?param1=foo,param2=html
> http://www.domain.com/struts2/queryName?param1=foo,param2=rss
>
> Include getter and setter for param2 in your action and set your 
> result strings as appropriate to get the results you want so, for 
> example after executing your query, you could include in your action 
> method;
>
> return getParam2()
> which would return xml,json,html or rss and then in your struts.xml 
> you'd specify
>
> <result name="xml">YourResultTypeForXML</result>
> <result name="json">YourResultTypeForJSON</result>
>
> etc etc
>
> Does this help.
>
> Regards
> Roger
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to