Implement permission control in struts2 CRUD (2)

Source: Internet
Author: User
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...
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.