mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 09:30:05 +08:00
增加 Utf8SseEmitter 处理 中文乱码问题
This commit is contained in:
parent
8b310c1dce
commit
4b5910f972
@ -0,0 +1,26 @@
|
|||||||
|
package cn.iocoder.yudao.module.ai.controller;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.server.ServerHttpResponse;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解决中文乱码
|
||||||
|
*
|
||||||
|
* @author fansili
|
||||||
|
* @time 2024/4/14 15:13
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
public class Utf8SseEmitter extends SseEmitter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void extendResponse(ServerHttpResponse outputMessage) {
|
||||||
|
super.extendResponse(outputMessage);
|
||||||
|
|
||||||
|
HttpHeaders headers = outputMessage.getHeaders();
|
||||||
|
headers.setContentType(new MediaType(MediaType.TEXT_EVENT_STREAM, StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user