struts2 StrutsPrepareAndExecuteFilter customization

允我心安 提交于 2019-12-06 14:56:17
Roman C

You should never do a customization of org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.

Even if it's not final and not package protected like in other frameworks, extending that filter is not necessary.

You should learn basics of the Struts2 architecture. from the Nutshell.

you can see the basic Struts2 flow. Struts2 is implemented as a filter to handle all requests and dispatch them to actions through a stack of interceptors that leverage most of the functionality and features of Struts2 framework.

So if you want to add some feature like authentication, then you should first think about extending it via the authentication interceptor. This interceptor should be configured to be invoked on every action from the incoming requests. See how it's done in struts2 adding interceptors in struts.xml for all action class.

Latter there's a link that you could use to write a custom interceptor for authentication purposes. See Is there a way to redirect to another action class without using on struts.xml

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