Skip to content

Instantly share code, notes, and snippets.

@sandipchitale
Last active May 12, 2023 03:35
Show Gist options
  • Save sandipchitale/d124b46f911975faacb68028f911a721 to your computer and use it in GitHub Desktop.
Save sandipchitale/d124b46f911975faacb68028f911a721 to your computer and use it in GitHub Desktop.
Get hold of current request #spring-web-mvc
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if (requestAttributes instanceof ServletRequestAttributes servletRequestAttributes) {
HttpServletRequest httpServletRequest = servletRequestAttributes.getRequest();
HttpServletResponse httpServletResponse= servletRequestAttributes.getResponse();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment