mirror of
https://gitee.com/incloudcode/yexuejc-springboot.git
synced 2025-07-19 01:59:31 +08:00
1.0.14 优化拦截规则:增加通配符 /**
This commit is contained in:
parent
686249f72b
commit
e8e3f9f2b1
@ -11,6 +11,7 @@ spring-boot-starter-parent:1.5.15.RELEASE
|
||||
```
|
||||
**update:** <br/>
|
||||
1. 升级依赖
|
||||
2. 优化拦截规则:增加通配符 /**
|
||||
#
|
||||
|
||||
#### version :1.0.13
|
||||
|
@ -12,6 +12,7 @@ import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* 过滤器配置
|
||||
@ -62,12 +63,28 @@ public class ValidationFilter implements Filter {
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
String sp = request.getServletPath();
|
||||
if (properties.getType() == 0) {
|
||||
if (properties.getIgnored().contains(sp)) {
|
||||
AtomicBoolean b = new AtomicBoolean(false);
|
||||
properties.getIgnored().forEach(it -> {
|
||||
if (it.endsWith("/**") && sp.indexOf(it.substring(0, it.length() - 3)) > -1) {
|
||||
b.set(true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (b.get() || properties.getIgnored().contains(sp)) {
|
||||
//不拦截
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!properties.getIntercepts().contains(sp)) {
|
||||
AtomicBoolean b = new AtomicBoolean(true);
|
||||
properties.getIntercepts().forEach(it -> {
|
||||
if (it.endsWith("/**") && sp.indexOf(it.substring(0, it.length() - 3)) > -1) {
|
||||
b.set(false);
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (b.get() || !properties.getIntercepts().contains(sp)) {
|
||||
//不拦截
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user