zj
2025-10-17 bbc4713b23778aebc1eb3d46cb04d539179d883d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.yami.trading.common.lang;
 
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
 
import javax.servlet.http.HttpServletRequest;
 
public class HttpContextUtil {
 
    public static HttpServletRequest getHttpServletRequest() {
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        if(requestAttributes == null){
            return null;
        }
        return ((ServletRequestAttributes) requestAttributes).getRequest();
    }
}