I can sort of understand your request, but there are a few things to
consider. First off, Struts tries really hard to be de-coupled from the
servlet / JSP specs, so what you're asking is not quite as easy and some
quick configuration hacks. Probably the easiest way to get what you want
is to configure an error-page in web.xml. If memory serves, it is
something like the following - 

    <error-page>
        <error-code>
            404
        </error-code>
        <location>
            /404.html
        </location>
    </error-page>

If you really want to try to handle it in Struts, the wildcard mapping
is the easiest thing, but as you said, it is likely to only be valid
within the the package that the wildcard is configured. 

Another option that may help you to get what you want is to look at
implementing a custom UnknownHandler. The JavaDoc (which doesn't say
much) is here - 

http://www.opensymphony.com/xwork/api/com/opensymphony/xwork2/UnknownHandler.html

For an example, check the conventions plugin (or codebehind) to see
their implementation. 

-Wes


On Sat, 2008-11-08 at 13:52 -0800, delsvr 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


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

Reply via email to