本文用于记录使用Spring MVC中的零散手札

1.在普通java类中获取HttpServletRequest对象

   在web.xml的listener节点加入

<listener>
       <listener-class>org.springframework.web.context.request.RequestContextListener </listener-class>
 </listener>
//需要使用的地方如下方法获取
        HttpServletRequest request =  ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();

 

 

相关文章:

  • 2021-07-12
  • 2021-07-23
  • 2021-08-27
  • 2021-08-30
  • 2021-11-11
  • 2021-10-04
  • 2021-12-02
  • 2021-12-18
猜你喜欢
  • 2021-09-29
  • 2022-03-08
  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
  • 2021-11-14
  • 2021-10-18
相关资源
相似解决方案