I just got done dealing with this issue as well. On my naive reading of the struts Dispatcher code, it appears to convert the Exceptions arising from non-existing actions into invocations of sendError() with the appropriate error code (when devMode is enabled, I actually get a 500 caused by an NPE deep in the Struts core but that's a separate issue). Anyways, this doesn't really work too well for me since I'm using sitemesh and I'd like to have my error page be decorated the same way as all my other pages with CSS applied and <@s.url> tags resolving properly. What I ended up doing to implement 404 / action-not-found handling was to add the <error-page> directive as Wes mentioned into web.xml - the <location> is then a 404.html that redirects to an actual Struts page-not-found page (using Restful2ActionMapper so I don't have to declare an action for it).
I'd be happy to learn of better/cleaner ways to implement this though :-). On Sat, Nov 8, 2008 at 2:52 PM, delsvr <[EMAIL PROTECTED]> wrote: > > I've been searching high and low for a solution to this simple problem, but > I > can't find anything: > > How can I get Struts2 to handle non-existing actions, globally? I thought a > global exception mapping would do it, but it doesn't seem like an exception > is being thrown when an action can't be found... or maybe one is, but it's > handled by the dispatcher? I've also tried a wildcard action mapping, but > this is insufficient as it only seems to match missing actions within its > respective namespace. > > If a missing action does throw an exception, may someone explain why this > struts.xml configuration is failing to catch it: > > <struts> > <constant name="struts.devMode" value="false" /> > <constant name="struts.action.extension" value="" /> > <constant name="struts.enable.SlashesInActionNames" value="true" /> > > <package name="default" namespace="/" extends="struts-default"> > <global-results> > <result name="error">/error/404.html</result> > </global-results> > > <global-exception-mappings> > <exception-mapping exception="java.lang.Exception" > result="error" /> > </global-exception-mappings> > > <action name="Index"> > <result>/index.html</result> > </action> > > </package> > > </struts> > > Thanks! > > -- delsvr > -- > View this message in context: > http://www.nabble.com/Struts2%3A-Handling-a-Missing-Action-%28404%29-tp20400822p20400822.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Allen Lee Center for the Study of Institutional Diversity [http://csid.asu.edu] School of Human Evolution and Social Change [http://shesc.asu.edu] College of Liberal Arts and Sciences Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402 480.727.0401 | Fax: 480.965.7671 | e-mail: [EMAIL PROTECTED]