Last active
June 10, 2018 04:57
-
-
Save ekirastogi/f127fd6c8a2b4a223b2c to your computer and use it in GitHub Desktop.
How to define Filter order in Filter Chain in Spring Boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ekiras.filter; | |
import org.springframework.core.annotation.Order; | |
import org.springframework.stereotype.Component; | |
import javax.servlet.*; | |
import java.io.IOException; | |
/** | |
* Created by ekansh on 22/10/15. | |
*/ | |
@Component | |
@Order(1) | |
public class SecurityFilter implements Filter{ | |
@Override | |
public void init(FilterConfig filterConfig) throws ServletException { | |
} | |
@Override | |
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { | |
System.out.println("###### security filter "); | |
chain.doFilter(request, response); | |
} | |
@Override | |
public void destroy() { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ekiras.filter; | |
import org.springframework.core.annotation.Order; | |
import org.springframework.stereotype.Component; | |
import javax.servlet.*; | |
import java.io.IOException; | |
/** | |
* Created by ekansh on 22/10/15. | |
*/ | |
@Component | |
@Order(2) | |
public class TrackingFilter implements Filter{ | |
@Override | |
public void init(FilterConfig filterConfig) throws ServletException { | |
} | |
@Override | |
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { | |
System.out.println("########## tracking filter"); | |
chain.doFilter(request,response); | |
} | |
@Override | |
public void destroy() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment