如何在spring中获取request对象
1个回答
展开全部
在xml中:
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
<此答/listener-class>
</listener>
代码实现:森行慧
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
注解实带轿现:
@Autowired
private HttpServletRequest request;
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
<此答/listener-class>
</listener>
代码实现:森行慧
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
注解实带轿现:
@Autowired
private HttpServletRequest request;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询