如何在自定义Listener中使用Spring容器管理的bean

2025-03-05 03:08:37
推荐回答(1个)
回答1:

要想使用request可以使用下面的方法:

在web点xml中配置一个监听

view plainprint?




org.springframework.web.context.request.RequestContextListener



之后就可以在程序使用了

view
plainprint?
HttpServletRequest request =
((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();