com.intters.util.RequestUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of - Show documentation
Show all versions of - Show documentation
Rapid development tool class
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();
}
}