Open GoogleCodeExporter opened 9 years ago
In Condition.java, about line 265:
> String fileName =
rule.getServletContext().getRealPath(hsRequest.getRequestURI);
If the app is deployed with contextpath "/test", the value of
hsRequest.getRequestURI() will be "/test/filename.txt".
Then, the var fileName will be "/home/path/test/test/filename.txt", but it
should be "/home/path/test/filename.txt". The key is that requestURI contains
contextpath.
In mapper of request, there is an attribute of mappingData named "requestPath",
which doesn't contain contextpath info. Unfortunately, this attribute can't be
read from request instance. So, I try to fix this like bellow:
String contextPath = rule.getServletContext().getContextPath(); // may be "/", "", or "/test"
if( contextPath != null){
contextPath = contextPath.replaceAll("^/", "");
}
String requestURI = hsRequest.getRequestURI();
requestURI = requestURI.replaceAll("^/"+contextPath, "");
String fileName = rule.getServletContext().getRealPath(requestURI);
And it works, that's all.
Original comment by i@luda.me
on 31 Dec 2014 at 3:22
btw, get the original uri:
> String originalUri =
request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
or with el:
> Original URI: ${requestScope['javax.servlet.forward.request_uri']}
get the full query path:
String queryPart = request.getQueryString() == null "" :
"?"+request.getQueryString();
String fullQueryPath = originalUri + queryPart; // or requestURI + queryPart;
Original comment by i@luda.me
on 31 Dec 2014 at 3:39
Original issue reported on code.google.com by
i@luda.me
on 31 Dec 2014 at 9:28