Commit 236d9536926c0d370a60efc6c3688212ed67654e
1 parent
3e6ab437
fix:【framework 框架】兼容 SpringBoot 2.X 版本的 API 加解密
Showing
1 changed file
with
7 additions
and
0 deletions
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java
| ... | ... | @@ -23,6 +23,7 @@ import org.springframework.http.HttpMethod; |
| 23 | 23 | import org.springframework.web.method.HandlerMethod; |
| 24 | 24 | import org.springframework.web.servlet.HandlerExecutionChain; |
| 25 | 25 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; |
| 26 | +import org.springframework.web.util.ServletRequestPathUtils; | |
| 26 | 27 | |
| 27 | 28 | import java.io.IOException; |
| 28 | 29 | |
| ... | ... | @@ -131,6 +132,12 @@ public class ApiEncryptFilter extends ApiRequestFilter { |
| 131 | 132 | @SuppressWarnings("PatternVariableCanBeUsed") |
| 132 | 133 | private ApiEncrypt getApiEncrypt(HttpServletRequest request) { |
| 133 | 134 | try { |
| 135 | + // 特殊:兼容 SpringBoot 2.X 版本会报错的问题 https://t.zsxq.com/kqyiB | |
| 136 | + if (!ServletRequestPathUtils.hasParsedRequestPath(request)) { | |
| 137 | + ServletRequestPathUtils.parseAndCache(request); | |
| 138 | + } | |
| 139 | + | |
| 140 | + // 解析 @ApiEncrypt 注解 | |
| 134 | 141 | HandlerExecutionChain mappingHandler = requestMappingHandlerMapping.getHandler(request); |
| 135 | 142 | if (mappingHandler == null) { |
| 136 | 143 | return null; | ... | ... |