找不到类Def。我究竟做错了什么?

时间:2019-04-10 19:26:11

标签: spring interceptor

尝试将拦截器添加到应用程序。获取未找到类Def错误,并在类路径中定义名称为'requestMappingHandlerAdapter'的bean创建错误。

@EnableWebMvc
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter{

    @Bean
    AuthorizationInterceptor authorizationInterceptor() {
        return new AuthorizationInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registery) {
        registery.addInterceptor(authorizationInterceptor());
    }
}

/

public class AuthorizationInterceptor extends HandlerInterceptorAdapter{
    @Override
    public boolean preHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler) 
                    throws Exception{
        String role = request.getHeader("role");
        System.out.println("PreHandle for Interceptor");
        System.out.println(request.getRequestURI()+"|||||||||||||"+role);
        if(request.getRequestURI().equals("/getEmails")||
                request.getRequestURI().equals("/screenings")||
                request.getRequestURI().equals("/softskillviolations")||
                request.getRequestURI().equals("/questionscores")||
                request.getRequestURI().equals("/printDAOs")||
                request.getRequestURI().equals("/getReport")||
                request.getRequestURI().equals("/getWeeksReport")||
                request.getRequestURI().equals("/getScreenerReports")||
                request.getRequestURI().equals("/getTotalReport")||
                request.getRequestURI().equals("/getReportWithEmail")) {
            if(role!="ROLE_PANEL"||role!="ROLE_QC"||role!="ROLE_TRAINER"||role!="ROLE_STAGING") {
                response.sendRedirect("/**/login");
                return false;
            }
        }
        return true;
    }
}

0 个答案:

没有答案