当从邮递员或任何浏览器点击并执行所有操作两次时,所有Http请求在zuul预过滤器中命中两次。我搜索了这个,但找不到答案。
我无法在此处添加我的实际实现,因此添加了虚拟代码。 我的预过滤器类是:
public class ApplicationGateway extends ZuulFilter {
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 1;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run()
{
LOGGER.debug("PRINT");
// PRINT is printing two times in each request
}
}
我的主要课程是:
@SpringBootApplication
@EnableZuulProxy
public class
Application
extends
SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ApplicationGateway preFilter() {
return new ApplicationGateway();
}
@Bean
public PostFilter postFilter() {
return new PostFilter();
}
@Bean
public ErrorFilter errorFilter() {
return new ErrorFilter();
}
@Bean
public RouteFilter routeFilter() {
return new RouteFilter();
}
@Bean
public ApplicationGateway getAuthenticatedFilter () {
return new ApplicationGateway();
}
}
答案 0 :(得分:1)
为什么从getAuthenticatedFilter返回AplicationGateway类型的bean,删除它,它应该工作