Struts 2 what to do when user inserts action which does not exist

两盒软妹~` 提交于 2019-12-06 14:05:34

Here you go :

 <default-action-ref name="index"/>

This action will be called if no match is found.

I use this in all my apps to avoid unwanted errors/warnings in the logs.

Documentation

Roman C

In fact exceptions are caught by the exception interceptor which is the first interceptor in the defaultStack that is allowing to handle exceptions occurred not only in action but also during interceptors invocations.

For this purpose you have already defined a configuration.

If you enter an URL that isn't mapped to any action configuration usually a dispatcher returns 404 error code. If you get a NullPointerException prior that result then it's something wrong with the project configuration.

It's difficult to tell what's going on without stacktrace. But if you want to handle cases where unknown URL is issued instead of dispatcher that handles it before, then you should look at this answer that could help you to define unknownHandler.

Read the note about supported version of Struts that has this feature.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!