码迷,mamicode.com
首页 > 其他好文 > 详细

spirng boot 添加过滤器

时间:2018-03-12 20:57:38      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:request   class   des   rgs   ota   java   pat   let   get   

@WebFilter(urlPatterns = "/*", filterName = "hystrixFilter")
public class MyFilter implements Filter {

	public void init(FilterConfig filterConfig) throws ServletException {
		
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		System.out.println("**************");
		System.out.println("过滤器");
		HystrixRequestContext ctx = HystrixRequestContext.initializeContext();
		try {
			chain.doFilter(request, response);
		} catch (Exception e) {
			
		} finally {
			ctx.shutdown();
		}
	}

	public void destroy() {
		
	}

}

  

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@ServletComponentScan
public class SaleApp {
	
	@Bean
	@LoadBalanced
	public RestTemplate getRestTemplate() {
		return new RestTemplate();
	}
	
	public static void main(String[] args) {
		new SpringApplicationBuilder(SaleApp.class).web(true).run(args);
	}

}

  

spirng boot 添加过滤器

标签:request   class   des   rgs   ota   java   pat   let   get   

原文地址:https://www.cnblogs.com/zfzf1/p/8550697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!