RequestContextHolder getHttpServletRequest

Posted tonggc1668

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RequestContextHolder getHttpServletRequest相关的知识,希望对你有一定的参考价值。

package me.zhengjie.common.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;

/**
 * 获取 HttpServletRequest
 * @author jie
 * @date 2018-11-24
 */
public class RequestHolder {

    public static HttpServletRequest getHttpServletRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }
}

 

以上是关于RequestContextHolder getHttpServletRequest的主要内容,如果未能解决你的问题,请参考以下文章

RequestContextHolder源码理解使用

RequestContextHolder getHttpServletRequest

RequestContextHolder与RequestContextUtils

RequestContextHolder.getRequestAttributes() null - Spring Security + Multi Tenant [关闭]

RequestContextHolder.getRequestAttributes()null - Spring Security + Multi Tenant [关闭]

RequestContextHolder