Browse Source

拦截器不起作用

chenyongxing 6 years ago
parent
commit
5eee86ede1

+ 0 - 10
src/main/java/com/yihu/hos/HosAdminApplication.java

@ -43,18 +43,8 @@ public class HosAdminApplication extends SpringBootServletInitializer {
        return application.sources(HosAdminApplication.class);
    }
    // 增加拦截器
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(webMvcInterceptor());
    }
    @Bean
    public SpringBeanUtil springBeanUtil(){return new SpringBeanUtil();}
    @Bean
    public WebMvcInterceptor webMvcInterceptor() {
        return new WebMvcInterceptor();
    }
}

+ 2 - 9
src/main/java/com/yihu/hos/config/WebMvcConfig.java

@ -1,8 +1,7 @@
package com.yihu.hos.config;
import com.yihu.hos.interceptor.WebMvcInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@ -12,17 +11,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
 * @vsrsion 1.0
 * Created at 2016/12/26.
 */
//@Configurable
@Component
public class WebMvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new WebMvcInterceptor());
    }
    @Bean
    public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
        HiddenHttpMethodFilter hiddenHttpMethodFilter= new HiddenHttpMethodFilter();
        return hiddenHttpMethodFilter;
    }
}