Created
September 18, 2014 09:42
-
-
Save yanhua365/ad03506e27f344ec2505 to your computer and use it in GitHub Desktop.
Spring配置RequestContextListener可以在任何地方得到HttpRequest对象。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//在任意的class下通过以下方法获取到HttpServletRequest | |
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- WEB.XML中配置相关的监听机制 --> | |
<listener> | |
<listener-class> | |
org.springframework.web.context.request.RequestContextListener | |
</listener-class> | |
</listener> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment