在路徑攔截中,加入攔截器,以下方式會報錯。
InterceptorRegistration registration = registry.addInterceptor(new LoginIntercept());
以下是真确姿勢。
@Autowired
LoginIntercept loginIntercept;
@Override
public void addInterceptors(InterceptorRegistry registry) {
//登入攔截的管理器
//攔截的對象會進入這個類中進行判斷
InterceptorRegistration registration = registry.addInterceptor(loginIntercept);
//預設所有路徑都被攔截
}