request.RequestContextListener

因为是使用spring mvc来作项目,所以脱离了HttpServletRequest做为参数,不可以直接使用request,要想使用request能够使用下面的方法:html

在web点xml中配置一个监听java

 

[html]  view plain copy print ?
  1. <listener>  
  2.         <listener-class>  
  3.             org.springframework.web.context.request.RequestContextListener  
  4.         </listener-class>  
  5. </listener>  

以后就能够在程序使用了web

 

  1. HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest()
相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息