Created
December 23, 2019 02:36
-
-
Save warriorg/528f974d3847bcb763bffe18540edb03 to your computer and use it in GitHub Desktop.
通过spring,在项目的任意位置获取当前Request
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
public static HttpServletRequest getRequest(){ | |
ServletRequestAttributes ra= (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); | |
HttpServletRequest request = ra.getRequest(); | |
return request; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment