1、记录问题,只有数据量很大的接口里面才会复现
2、只有经过gateway的,才会复现,而且是偶现

3、解决方案,gateway添加代码
super.writeWith(fluxBody.buffer().map(dataBuffers -> {
DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
DataBuffer join = dataBufferFactory.join(dataBuffers);
byte[] content = new byte[join.readableByteCount()];
join.read(content);
DataBufferUtils.release(join);
String responseData = new String(content, Charsets.UTF_8);
});
)
解决方案链接地址:SpringCloud框架:经由gateway网关转接的接口返回的json数据中部分中文偶尔出现乱码的问题 - 我命倾尘 - 博客园
本文主要探讨了在Spring Cloud Gateway中遇到的一个偶发性接口返回JSON数据中文乱码的问题。该问题仅在数据量较大且通过Gateway转发时出现。解决方案是通过在Gateway端添加代码,将DataBuffer转换为字符串,确保内容正确编码为UTF-8,从而避免乱码现象。
773

被折叠的 条评论
为什么被折叠?



