标签:Servle frame 文件 bsp attr request 监听器 contex class
1.在web.xml文件中添加监听器,然后通过注解注入request:
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
@Autowired
private HttpSession session;
@Autowired
private HttpServletRequest request;
2.直接在service层普通类中获取
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
Spring在service层获取session和request
标签:Servle frame 文件 bsp attr request 监听器 contex class
原文地址:https://www.cnblogs.com/caozx/p/11506848.html