新建HttpServletRequest对象

1、导入的包:
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

2、获取HttpServletRequest对象:
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpSession session = request.getSession();

  

posted @ 2022-04-18 15:57  八英里  阅读(2039)  评论(0编辑  收藏  举报