Last active
February 5, 2021 07:38
-
-
Save eisenreich/6ab40616a9e694bc2220c68ec3a01455 to your computer and use it in GitHub Desktop.
Build new request from path (Spring > 2.2.0.RELEASE)
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
private HttpServletRequest buildRequestFromPath(final HttpServletRequest request, final String path) { | |
return new HttpServletRequestWrapper(request) { | |
@Override | |
public String getRequestURI() { | |
return path; | |
} | |
@Override | |
public String getPathInfo() { | |
return path; | |
} | |
@Override | |
public Object getAttribute(final String name) { | |
if (name.equals(UrlPathHelper.PATH_ATTRIBUTE)) { | |
return path; | |
} | |
return super.getAttribute(name); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment