브라우저 → 필터(Filter) → DispatcherServlet → 인터셉터(preHandle) → Controller
| 위임 ← 인터셉터(postHandle) ←
← 인터셉터(afterCompletion) jsp
스프링 프레임워크
- 의존성 추가 없음
- @Component(”xxx”)
public class MyHandlerInterceptor extends HandlerInterceptorAdapter {}
필요한 메서드 재정의해서 사용 - servlet-context.xml
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/loginCheck/*"/>
<ref bean="xxx"/>
</mvc:interceptor>
스프링 부트
- 의존성 추가 없음
- @Component(”xxx”)
public class MyHandlerInterceptor implements HandlerInterceptor {}
⇒ 필요한 메서드 재정의해서 사용
왜? default 메서드로 되어있음
( HandlerInterceptorAdaptor는 deprecated 됨 ) - servlet-context.xml 대신에 빈(설정목적)을 이용해서 Interceptor 등록한다.
@Configuration
public class WebConfig implements WebMvcConfigurer{
//이전 servlet-context.xml 에서 했던 여러 기능을 가진 메서드 재정의해서 사용
}
https://docs.spring.io/spring-boot/docs/2.7.16/reference/html/web.html#web
Web
Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and servlet-based web applications. It occurs as part of closing the application context and is performed in the earliest
docs.spring.io
@Configuration
public class WebConfig implements WebMvcConfigurer{
//이전 servlet-context.xml 에서 했던 여러 기능을 가진 메서드 재정의해서 사용
@Autowired
MyHandlerInterceptor interceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(interceptor)
.addPathPatterns("/login", "/mypage");
}
}







'Framework > SPRING BOOT' 카테고리의 다른 글
@Value (0) | 2023.09.25 |
---|---|
springboot에서 설정 정보 파일 (0) | 2023.09.25 |
file upload (0) | 2023.09.25 |
@RestController (0) | 2023.09.25 |
JSON 처리(@RequestBody) (0) | 2023.09.25 |
브라우저 → 필터(Filter) → DispatcherServlet → 인터셉터(preHandle) → Controller
| 위임 ← 인터셉터(postHandle) ←
← 인터셉터(afterCompletion) jsp
스프링 프레임워크
- 의존성 추가 없음
- @Component(”xxx”)
public class MyHandlerInterceptor extends HandlerInterceptorAdapter {}
필요한 메서드 재정의해서 사용 - servlet-context.xml
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/loginCheck/*"/>
<ref bean="xxx"/>
</mvc:interceptor>
스프링 부트
- 의존성 추가 없음
- @Component(”xxx”)
public class MyHandlerInterceptor implements HandlerInterceptor {}
⇒ 필요한 메서드 재정의해서 사용
왜? default 메서드로 되어있음
( HandlerInterceptorAdaptor는 deprecated 됨 ) - servlet-context.xml 대신에 빈(설정목적)을 이용해서 Interceptor 등록한다.
@Configuration
public class WebConfig implements WebMvcConfigurer{
//이전 servlet-context.xml 에서 했던 여러 기능을 가진 메서드 재정의해서 사용
}
https://docs.spring.io/spring-boot/docs/2.7.16/reference/html/web.html#web
Web
Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and servlet-based web applications. It occurs as part of closing the application context and is performed in the earliest
docs.spring.io
@Configuration
public class WebConfig implements WebMvcConfigurer{
//이전 servlet-context.xml 에서 했던 여러 기능을 가진 메서드 재정의해서 사용
@Autowired
MyHandlerInterceptor interceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(interceptor)
.addPathPatterns("/login", "/mypage");
}
}







'Framework > SPRING BOOT' 카테고리의 다른 글
@Value (0) | 2023.09.25 |
---|---|
springboot에서 설정 정보 파일 (0) | 2023.09.25 |
file upload (0) | 2023.09.25 |
@RestController (0) | 2023.09.25 |
JSON 처리(@RequestBody) (0) | 2023.09.25 |