This commit is contained in:
wangw 2025-11-07 13:25:26 +08:00
parent 07b55f8508
commit 4f5661bff3
1 changed files with 4 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
@ -24,6 +25,9 @@ public class CorsFilter implements Filter {
throws IOException, ServletException {
// traceId
Map<String, String> copyOfContextMap = MDC.getCopyOfContextMap();
if(copyOfContextMap == null){
copyOfContextMap = new HashMap<>();
}
copyOfContextMap.put("traceId",applicationName + IdUtil.getSnowflakeNextId());
MDC.setContextMap(copyOfContextMap);
HttpServletResponse response = (HttpServletResponse) resp;