欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

手动获取request对象

程序员文章站 2022-05-24 14:20:42
...
手动获取request对象
struts2:HttpServletRequest request = ServletActionContext.getRequest();
springMVC:
配置web.xml
<</span>listener>
<</span>listener-class>
org.springframework.web.context.request.RequestContextListener
</</span>listener-class>
</</span>listener>

后台中
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();