All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.lastwhisper.trace.common.RequestHelper Maven / Gradle / Ivy

The newest version!
package cn.lastwhisper.trace.common;

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;

/**
 * 获取原生HttpServletRequest
 * @author lastwhisper
 * @date 2020/2/28
 */
public class RequestHelper {

    /**
     * 获取原生HttpServletRequest
     */
    public static HttpServletRequest getHttpServletRequest() {
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        return requestAttributes == null ? null : ((ServletRequestAttributes) requestAttributes).getRequest();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy