In the article "Implementing permission control in crud of struts2", I raised a question, that is, after implementing the permission interceptor, each action must be configured with an interceptor before you can perform a permission check after calling it. After reading the information today, you can set the default interceptor, when no interceptor is displayed, the default interceptor is used for this purpose. In the future, the default "permission interceptor" will be used for methods in the package. The example configuration file is as follows:
<Package name = "admin" extends = "struts-Default" namespace = "/admin">
<Interceptors>
<Interceptor name = "auth"
Class = "com. waimai. utils. authorizationinterceptor"/>
</Interceptors>
<Default-interceptor-ref name = "auth"/>
<Global-Results>
<Result name = "login" type = "Redirect">
/Security/login. jsp
</Result>
</Global-Results>
<Action name = "list" class = "com. waimai. Web. caitypeaction"
Method = "list">
<Result> listcaitype. jsp </result>
</Action>
<Action name = "edit" class = "com. waimai. Web. caitypeaction"
Method = "LOAD">
<Result> editcaitype. jsp </result>
</Action>
<Action name = "Store" class = "com. waimai. Web. caitypeaction"
Method = "Store">
<Result name = "input" type = "dispatcher">
Editcaitype. jsp
</Result>
<Result type = "Redirect"> list. Action </result>
</Action>
<Action name = "Remove" class = "com. waimai. Web. caitypeaction"
Method = "Remove">
<Result type = "Redirect"> list. Action </result>
</Action>
</Package>
In the above configuration, we can see that the global result is also based on the problem that we need to configure the interceptor for every action. In fact, the global result is to reduce duplication, does the default interceptor support global interceptors? It tastes like this...