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

com.intters.util.RequestUtil Maven / Gradle / Ivy

The newest version!
package com.intters.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 请求上下文工具类
 *
 * @author Ruison
 * @date 2018/8/17.
 */
public class RequestUtil {
    /**
     * 获取上下文的Request
     *
     * @return {@link HttpServletRequest}
     */
    public static HttpServletRequest getRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }

    /**
     * 获取上下文的Response
     *
     * @return {@link HttpServletResponse}
     */
    public static HttpServletResponse getResponse() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy