从Spring容器中获取bean的几种方式

2025-04-14 06:50:04
推荐回答(1个)
回答1:

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

  在web点xml中配置一个监听

  view plainprint?
  
  
  org.springframework.web.context.request.RequestContextListener
  

  

  之后就可以在程序使用了