refactor(security): 更新验证码过滤器请求匹配器实现- 将 AntPathRequestMatcher 替换为 PathPatternRequestMatcher- 使用新的匹配器工厂方法创建登录路径匹配器-保持验证码验证逻辑不变

fix(web): 设置响应字符编码为UTF-8

- 添加 StandardCharsets 导入- 在响应处理中显式设置字符编码
- 确保响应内容正确编码避免乱码问题
This commit is contained in:
theo
2025-10-16 10:25:34 +08:00
parent b6bfc55b3b
commit a08ac338c0
2 changed files with 6 additions and 3 deletions

View File

@@ -12,7 +12,8 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpMethod;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.filter.OncePerRequestFilter;
import java.io.IOException;
@@ -26,7 +27,7 @@ import java.io.IOException;
*/
public class CaptchaValidationFilter extends OncePerRequestFilter {
private static final AntPathRequestMatcher LOGIN_PATH_REQUEST_MATCHER = new AntPathRequestMatcher(SecurityConstants.LOGIN_PATH, HttpMethod.POST.name());
private static final RequestMatcher LOGIN_PATH_REQUEST_MATCHER = PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.POST,SecurityConstants.LOGIN_PATH);
public static final String CAPTCHA_CODE_PARAM_NAME = "captchaCode";
public static final String CAPTCHA_KEY_PARAM_NAME = "captchaKey";