@WebFilter("/*")
public class MyFilter extends HttpFilter implements Filter {
public MyFilter() {
super();
// TODO Auto-generated constructor stub
}
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
// place your code here
// 정수기처럼 미리 필터로 거르는 것
System.out.println("MyFilter.doFilter()호출됨");
// pass the request along the filter chain
// 다음 filter에 연결하는 메서드
chain.doFilter(request, response);
}
public void init(FilterConfig fConfig) throws ServletException {
// TODO Auto-generated method stub
}
}
필터 쓰는 이유 : 서블릿은 서블릿만 가능하게. 보안에 대한거나 그런 작업 미리 필요할 때 씀. 스프링시큐리티의 근간.
어떤 url을 요청할 때라도 doFilter메서드부터 호출
'프레임워크 > Spring' 카테고리의 다른 글
라이브러리 dependency로 추가하고 setting 하기 (0) | 2023.10.24 |
---|---|
Maven Project 생성 (0) | 2023.10.24 |
web module version (0) | 2023.10.24 |
Listener (0) | 2023.10.24 |
리플랙션(Reflection) (0) | 2023.10.23 |