用SseEmitter 返回数据会成乱码,原因是SseEmitter 默认使用得不是UTF-8,继承一下,重写就好了
public class SseEmitterUTF8 extends SseEmitter {
public SseEmitterUTF8(Long timeout) {
super(timeout);
}
@Override
protected void extendResponse(ServerHttpResponse outputMessage) {
super.extendResponse(outputMessage);
HttpHeaders headers = outputMessage.getHeaders();
headers.setContentType( new MediaType("text", "event-stream", Charset.forName("UTF-8")));
}
}