forked from zhuzhengping911/MySpringBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebConfiguration.java
More file actions
27 lines (24 loc) · 837 Bytes
/
Copy pathWebConfiguration.java
File metadata and controls
27 lines (24 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.Filter;
import org.apache.catalina.filters.RemoteIpFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
/**
* Created by zhuzhengping on 2017/2/12.
* 过滤器,定义filter继承servlet的filter
*/
public class WebConfiguration {
@Bean
public RemoteIpFilter remoteIpFilter(){
return new RemoteIpFilter();
}
@Bean
public FilterRegistrationBean testFilterRegistration(){
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new MyFilter());
registration.addUrlPatterns("/*");
registration.addInitParameter("paramName","paramValue");
registration.setName("MyFilter");
registration.setOrder(1);
return registration;
}
}