@Configuration
public class PermissionInterceptor implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
HandlerInterceptor handlerInterceptor=new HandlerInterceptor() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object hander) throws Exception {
//逻辑判断区
return true;
};
registry.addInterceptor(handlerInterceptor).addPathPatterns("需要拦截的api,不填就全部拦截")
.excludePathPatterns("排除不需要拦截的api");
}
java拦截器配置
最新推荐文章于 2023-10-23 12:57:45 发布