InterceptorConfig.java

example/config/InterceptorConfig.java

package com.example.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer{

    @Autowired
    HandlerInterceptor interceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
            .addPathPatterns("/**")
            .excludePathPatterns(
                "/member/login/**", 
                "/member/logout/**", 
                "/resources/**",
                "/item/image/**",
                "/shop/cart/**",
                "/item/subimage/**",
                "/css/**"
            );
    }
}

좋은 웹페이지 즐겨찾기