Introduction of Struts 2 Interceptors by R4R Team

Struts 2 Interceptor

In the Apache Struts 2 framework interceptors plays a very important role. Interceptors are conceptually the same as servlet filters or the JDKs Proxy class. Interceptors  can execute code before and after an Action is invoked. Most of the framework's core functionality is implemented as Interceptors. Features like double-submit guards, type conversion, object population, validation, file upload, page preparation, and more, are all implemented with the help of Interceptors. Each and every Interceptor is pluggable, so you can decide exactly which features an Action needs to support.

Interceptors can be configured on a per-action basis. Your own custom Interceptors can be mixed-and-matched with the Interceptors bundled with the framework. Interceptors "set the stage" for the Action classes, doing much of the "heavy lifting" before the Action executes.

Interceptors allow for crosscutting functionality to be implemented separately from the action as well as the framework. You can achieve the following using interceptors:

    • Providing pre-processing logic before the action is called.
    • Providing post-processing logic after the action is called.
    • Catching exceptions so that alternate processing can be performed.


Leave a Comment:
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!