RequestContextHolder

2019-12-09  本文已影响0人  荒天帝886

https://www.cnblogs.com/shuilangyizu/p/8621669.html

package com.repository.manage.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
* 获取当前请求信息
 * @author km005
 * @date 2019-12-09 3:33 下午
 */
@Slf4j
public class Current {
    public static HttpServletRequest getRequest() {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        assert attributes != null;
        return attributes.getRequest();
    }
}
上一篇下一篇

猜你喜欢

热点阅读