From 68aeb581cc899f1fa284e6e353e0eb67cb244005 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Wed, 15 Apr 2026 13:13:26 +0800
Subject: [PATCH] 修复脱敏不生效问题
---
ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/GatewayExceptionHandler.java | 18 ++++--------------
1 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/GatewayExceptionHandler.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/GatewayExceptionHandler.java
index 0a8e44a..eaf38d9 100644
--- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/GatewayExceptionHandler.java
+++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/GatewayExceptionHandler.java
@@ -3,17 +3,13 @@
import org.springframework.cloud.gateway.support.NotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
-import org.springframework.core.io.buffer.DataBufferFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.server.ServerWebExchange;
-import com.alibaba.fastjson.JSON;
-import com.ruoyi.common.core.domain.R;
+import org.springframework.web.server.WebExceptionHandler;
+import com.ruoyi.common.core.utils.ServletUtils;
import reactor.core.publisher.Mono;
/**
@@ -23,7 +19,7 @@
*/
@Order(-1)
@Configuration
-public class GatewayExceptionHandler implements ErrorWebExceptionHandler
+public class GatewayExceptionHandler implements WebExceptionHandler
{
private static final Logger log = LoggerFactory.getLogger(GatewayExceptionHandler.class);
@@ -55,12 +51,6 @@
log.error("[网关异常处理]请求路径:{},异常信息:{}", exchange.getRequest().getPath(), ex.getMessage());
- response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
- response.setStatusCode(HttpStatus.OK);
-
- return response.writeWith(Mono.fromSupplier(() -> {
- DataBufferFactory bufferFactory = response.bufferFactory();
- return bufferFactory.wrap(JSON.toJSONBytes(R.fail(msg)));
- }));
+ return ServletUtils.webFluxResponseWriter(response, msg);
}
}
\ No newline at end of file
--
Gitblit v1.9.3