Java web Filter filter

Filter: Filter

When the resource access server, the filter may be intercepted request, complete some special features

As a filter:

  • General Procedure for completion by
    • Login authentication
    • Agree encoding process
    • Sensitive character filtering

step

  • Defined class that implements the interface Filter
  • Replication method
  • Configuration intercept path
    • web.xml
    • annotation

Life cycle

  • After the server starts, create Filter object and then call the init method
  • DoFilter method performed upon request intercepting
  • After the server is shut down, Filter object is destroyed

Detailed Filter Configuration

  • Interception path configuration:
    • Specific resource path: /index.jsp
    • Interception directory: / user / *
    • Extension intercepts: * jsp.
    • Block all resources: / *
  • Intercept mode configuration:
    • Notes Configuration
      • Set dispatcherTypes property
        • REQUEST: default browser requests a resource
        • FORWARD: Forwarding access to resources
        • INCLUDE: includes access to resources
        • ERROR: error Jump Resources
        • ASYNC: asynchronous access resources
    • web.xml Configuration
      • Settings <dispatcher> <dispatcher> to
  • Filter chain
    • After performing the first return
    • Filter order
      • Notes Configuration
        • Compare string comparison rules in accordance with the class name, the smaller first execution
Published 70 original articles · won praise 43 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_25884515/article/details/103992678