You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Greg Huber <gr...@gmail.com> on 2017/09/13 07:39:17 UTC

Obscure struts 404's

For a bogus /test.action I get

There is no Action mapped for namespace [/] and action name [test]
associated with context path []

If not in dev mode, would it not be better to just to a more generic 404
not found, rather than a known struts reply?

Re: Obscure struts 404's

Posted by Greg Huber <gr...@gmail.com>.
Tried this but wanted a uniform error.

for /test/test

I get :

Status Code: 404
Message: /ddd/test
Type:
Exception: The file that you requested could not be found on this server


for /test/test.action

Status Code:
Message:
Type:
Exception: The file that you requested could not be found on this server


##

<default-action-ref name="404me" />
<action name="404me">
            <result>
                <param name="location">/WEB-INF/jsps/errors/404.jsp</param>
                <param name="message">"ok"</param>
            </result>
        </action>

Need to mimic the errors and handle dev mode, so may need an action for
this.  Will look into this some more.  Thanks.

On 13 September 2017 at 08:42, Yasser Zamani <ya...@live.com> wrote:

> At [1] there is an answer as below:
>
> > Usually, if an action is requested, and the framework can't map the
> request to an action name, the result will be the usual "404 - Page not
> found" error. But, if you would prefer that an omnibus action handle any
> unmatched requests, you can specify a default action. If no other action
> matches, the default action is used instead.
> >
> > <package name="Hello" extends="action-default">
> >
> >     <default-action-ref name="UnderConstruction"/>
> >
> >     <action name="UnderConstruction">
> >         <result>/UnderConstruction.jsp</result>
> >     </action>
> >
> >     ...
> > There are no special requirements for the default action. Each package
> can have its own default action, but there should only be one default
> action per namespace.
> >
> > One to a Namespace
> >
> > The default action features should be set up so that there is only one
> default action per namespace. If you have multiple packages declaring a
> default action with the same namespace, there is no guarantee which action
> will be the default.
>
> [1]
> https://struts.apache.org/docs/action-configuration.
> html#ActionConfiguration-ActionDefault
>
> On 9/13/2017 12:09 PM, Greg Huber wrote:
> > For a bogus /test.action I get
> >
> > There is no Action mapped for namespace [/] and action name [test]
> > associated with context path []
> >
> > If not in dev mode, would it not be better to just to a more generic 404
> > not found, rather than a known struts reply?
> >
>

Re: Obscure struts 404's

Posted by Yasser Zamani <ya...@live.com>.
At [1] there is an answer as below:

> Usually, if an action is requested, and the framework can't map the request to an action name, the result will be the usual "404 - Page not found" error. But, if you would prefer that an omnibus action handle any unmatched requests, you can specify a default action. If no other action matches, the default action is used instead.
> 
> <package name="Hello" extends="action-default">
>  
>     <default-action-ref name="UnderConstruction"/>
>  
>     <action name="UnderConstruction">
>         <result>/UnderConstruction.jsp</result>
>     </action>
>  
>     ...
> There are no special requirements for the default action. Each package can have its own default action, but there should only be one default action per namespace.
> 
> One to a Namespace
> 
> The default action features should be set up so that there is only one default action per namespace. If you have multiple packages declaring a default action with the same namespace, there is no guarantee which action will be the default.

[1] 
https://struts.apache.org/docs/action-configuration.html#ActionConfiguration-ActionDefault

On 9/13/2017 12:09 PM, Greg Huber wrote:
> For a bogus /test.action I get
> 
> There is no Action mapped for namespace [/] and action name [test]
> associated with context path []
> 
> If not in dev mode, would it not be better to just to a more generic 404
> not found, rather than a known struts reply?
> 

Re: Obscure struts 404's

Posted by Greg Huber <gr...@gmail.com>.
I will look into this, thanks.

On 13 September 2017 at 09:15, Lukasz Lenart <lu...@apache.org>
wrote:

> 2017-09-13 10:00 GMT+02:00 Greg Huber <gr...@gmail.com>:
> > struts.exception.missing-package-action.with-context=Not found
> >
> > This works but in dev mode also.
>
> Right ... you can always implement your own DispatcherErrorHandler and
> register it with "struts.dispatcher.errorHandler"
>
> http://struts.apache.org/core-developers/dispatcher.html
>
> but this can be an overkill ;-) Feel free to register a ticket in JIRA
> and we can add a dedicated error key to specify custom error message
> in case of 404.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Obscure struts 404's

Posted by Lukasz Lenart <lu...@apache.org>.
2017-09-13 10:00 GMT+02:00 Greg Huber <gr...@gmail.com>:
> struts.exception.missing-package-action.with-context=Not found
>
> This works but in dev mode also.

Right ... you can always implement your own DispatcherErrorHandler and
register it with "struts.dispatcher.errorHandler"

http://struts.apache.org/core-developers/dispatcher.html

but this can be an overkill ;-) Feel free to register a ticket in JIRA
and we can add a dedicated error key to specify custom error message
in case of 404.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Obscure struts 404's

Posted by Greg Huber <gr...@gmail.com>.
struts.exception.missing-package-action.with-context=Not found

This works but in dev mode also.

On 13 September 2017 at 08:50, Lukasz Lenart <lu...@apache.org>
wrote:

> 2017-09-13 9:39 GMT+02:00 Greg Huber <gr...@gmail.com>:
> > For a bogus /test.action I get
> >
> > There is no Action mapped for namespace [/] and action name [test]
> > associated with context path []
> >
> > If not in dev mode, would it not be better to just to a more generic 404
> > not found, rather than a known struts reply?
>
> Can you try defining a key
> "struts.exception.missing-package-action.with-context" in your message
> properties file? e.g.:
>
> struts.exception.missing-package-action.with-context=Not found
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Obscure struts 404's

Posted by Lukasz Lenart <lu...@apache.org>.
2017-09-13 9:39 GMT+02:00 Greg Huber <gr...@gmail.com>:
> For a bogus /test.action I get
>
> There is no Action mapped for namespace [/] and action name [test]
> associated with context path []
>
> If not in dev mode, would it not be better to just to a more generic 404
> not found, rather than a known struts reply?

Can you try defining a key
"struts.exception.missing-package-action.with-context" in your message
properties file? e.g.:

struts.exception.missing-package-action.with-context=Not found


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org