Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ufuk/28a3380ecb44d6003a0939a381759a8a to your computer and use it in GitHub Desktop.
Save ufuk/28a3380ecb44d6003a0939a381759a8a to your computer and use it in GitHub Desktop.
To get the request and response objects in Spring MVC projects you can use this code
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
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