In the book ‘Struts2 in Action‘, its stated :
while actions that don’t define any interceptor-refs themselves will
inherit the default interceptors, as soon as an action declares its
own interceptors, it loses that automatic default and must explicitly
name the defaultStack in order to use it.
But in so many example on the net, I see that the action section declares its own interceptors, but still doesn’t need to declare the default stack like here . Their code is :
<action name="TestLogger" class="vaannila.TestLoggerAction">
<interceptor-ref name="logger" />
<result name="success">/success.jsp</result>
</action>
Is there something I am missing ?
That should be an example to show how to configure custom interceptors.Though you can declare and apply this single interceptor but that means other interceptor being provides by the Framework will not gona get executed and most of the functionality provides by framework will not come in to act.
By what author is trying to explain is that if we define our own interceptor stack and do not inherit default stack or not define other interceptor being used by the framework most of the functionalities will be missing
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.The Interceptors are defined in a stack that specifies the execution order and in most cases while defining our custom interceptor stack we end up either extending default-stack or define the provided interceptor execution in our own way.
Have a look at how interceptor stack is actually being declared by the framework
So in short if you see interceptor stack is a set of interceptors grouped together and they will get fired in the sequence as defined in the stack.
One more example to define a custom interceptor
creating_a_login_interceptor
Hope this will give you some idea