Yes, you can tell Struts to not use any action extension at all. I'm doing that right now for a Restful application I developed. I haven't tried, but you might be able to use wildcards to match the extension in the action mapping and perhaps use a custom dispatcher result to determine which actual result should be executed:
<action name="queryName.*" class="com.example.MyAction"> <result type="extDispatch"> <param name="extension">{0}</param> </result> </action> I'd love to see this type of feature either built into Struts or as a plugin, so if you discover a solution that involves Struts improvements, please file a JIRA ticket. Thanks, Don On 5/25/07, Kevin Conroy <[EMAIL PROTECTED]> wrote:
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]