springboot-FilterRegistrationBean
主要用来对servlet filter进行自定义,比如设置order。
先写一个普通的filter:
public class FilterDemo implements Filter {
private final Logger log = LoggerFactory.getLogger(FilterDemo.class); @Override
public void destroy() {
log.info("" + getClass() + " destroy"); } @Override
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {
log.info( " doFilter " );
arg2.doFilter(arg0, arg1); } @Override
public void init(FilterConfig arg0) throws ServletException {
log.info("" + getClass() + " init"); } }
配置如下:
@Configuration
public class WebComponent2Config { @Bean
public FilterRegistrationBean filterDemo3Registration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(filterDemo3());
registration.addUrlPatterns("/*");
registration.setName("filterDemo3");
registration.setOrder();
return registration;
} @Bean
public FilterRegistrationBean filterDemo4Registration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(filterDemo4());
registration.addUrlPatterns("/*");
registration.setName("filterDemo4");
registration.setOrder();
return registration;
} @Bean
public Filter filterDemo3() {
return new FilterDemo3();
} @Bean
public Filter filterDemo4() {
return new FilterDemo4();
} }
springboot-FilterRegistrationBean的更多相关文章
- springboot之filter/listener/servlet
简介 SpringBoot可以简化开发流程,但是在其中如何使用传统的J2EE servlet/listener/filter呢 @Bean配置 在Configuration类中加入filter和ser ...
- spring boot 初试,springboot入门,springboot helloworld例子
因为项目中使用了spring boot ,之前没接触过,所以写个helloworld玩玩看,当做springboot的一个入门例子.搜索 spring boot.得到官方地址:http://proje ...
- 一个最小化的SpringBoot项目
项目结构 项目基于Maven管理,注意使用了父pom <parent> <groupId>org.springframework.boot</groupId> &l ...
- springboot日志
1.日志 Spring Boot内部日志系统使用的是Commons Logging,但开放底层的日志实现.默认为会Java Util Logging, Log4J, Log4J2和Logback提供配 ...
- spring-boot系列:初试spring-boot
部署父工程 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http: ...
- SpringBoot笔记一
1 开始 1.1 spring介绍 Spring Boot使开发独立的,产品级别的基于Spring的应用变得非常简单,你只需"just run". 我们为Spring平台及第三方库 ...
- springboot(二):web综合开发
上篇文章介绍了spring boot初级教程:spring boot(一):入门篇,方便大家快速入门.了解实践Spring boot特性:本篇文章接着上篇内容继续为大家介绍spring boot的其它 ...
- springboot + shiro + cas4.2.7 实战
1. 下载地址 https://github.com/apereo/cas/archive/v4.2.7.zip 2. 解压后, 用intellj idea 打开 3. 执行 gradle build ...
- SpringBoot整合Mybatis之项目结构、数据源
已经有好些日子没有总结了,不是变懒了,而是我一直在奋力学习springboot的路上,现在也算是完成了第一阶段的学习,今天给各位总结总结. 之前在网上找过不少关于springboot的教程,都是一些比 ...
- Springboot与Mybatis整合
最近自己用springboot和mybatis做了整合,记录一下: 1.先导入用到的jar包 <dependency> <groupId>org.springframework ...
随机推荐
- Razor 3、MVC 5
Razor 3 需要vs 2012 update 4 才可以 需要装一个 Microsoft ASP.NET and Web Tools 2013.1 才会有 MVC 5
- kdump 的使用在linux崩溃时
Centos7/RHEL7 开启kdump 翻译 2017年12月18日 16:58:28 标签: kernel / kdump / crash / centos 437 原文链接<How to ...
- 使用Squid搭建HTTPS代理服务器
由于经常去的一些国外网站如Google.Blogspot.Wordpress被"出现了技术问题",访问不了,于是我在自己的DigitalOcean云主机上搭建了一个 Squid代理 ...
- Ubuntu下创建JerBrains系列软件的快捷方式
以pycharm为例: 终端输入:sudo gedit /usr/share/applications/Pycharm.desktop模板: [Desktop Entry]Type=Applicati ...
- ASP.NET管道技术
Asp.net mvc是基于dnf(.net framework )实现了代码分离的开源框架.ASP.NET MVC框架拥有极强的定制以及扩展的特性.本文梳理了ASP.NET MVC的管道(pipel ...
- Android实现短信监听并且转发到指定的手机号,转发后不留痕
转载:http://blog.csdn.net/swqqcs/article/details/7252419 通过这些代码也可以对远程手机实现短信控制.有兴趣的可以自己改一下,说一下简单的原理,要实现 ...
- retrival and clustering: week 2 knn & LSH 笔记
华盛顿大学 <机器学习> 笔记. knn k-nearest-neighbors : k近邻法 给定一个 数据集,对于查询的实例,在数据集中找到与这个实例最邻近的k个实例,然后再根据k个最 ...
- Python:简述 线程、进程和协程
Python线程 定义:Threading用于提供线程相关的操作,线程是应用程序中工作的最小单元. #!/usr/bin/env python # -*- coding:utf-8 -*- impor ...
- lumen 获得当前uri 如/xxx/{id}
因为想实现通过url判断是否有权限,所有需要拿到当前的route方法的name,如下 $api->get('role/grant/{id}', 'RoleController@getGrant' ...
- python3 - property的使用
传统的绑定属性值,会把属性暴露出去,而且无法检查参数是否合法,如下: class Test(object): def __int__(self,age): self.age = age 为了检查参数 ...