mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	增加 Utf8SseEmitter 处理 中文乱码问题
This commit is contained in:
		| @@ -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)); | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 cherishsince
					cherishsince