下面代码中有Globals.ORIGINAL_URI_KEY,INCLUDE_PATH_INFO,INCLUDE_SERVLET_PATH等东东不知道代表什么??还有我知道猜测到这段代码是解析request的url地址的,但是怎么解析却不是很懂,晕晕的,有高人能指点一下吗,不胜感激啊!!!
protected String processPath(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
String path; // Set per request the original path for postback forms
if (request.getAttribute(Globals.ORIGINAL_URI_KEY) == null) {
request.setAttribute(Globals.ORIGINAL_URI_KEY, request.getServletPath());
} // For prefix matching, match on the path info (if any)
path = (String) request.getAttribute(INCLUDE_PATH_INFO); if (path == null) {
path = request.getPathInfo();
} if ((path != null) && (path.length() > 0)) {
return (path);
} // For extension matching, strip the module prefix and extension
path = (String) request.getAttribute(INCLUDE_SERVLET_PATH); if (path == null) {
path = request.getServletPath();
} String prefix = moduleConfig.getPrefix(); if (!path.startsWith(prefix)) {
String msg = getInternal().getMessage("processPath"); log.error(msg + " " + request.getRequestURI());
response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); return null;
} path = path.substring(prefix.length()); int slash = path.lastIndexOf("/");
int period = path.lastIndexOf("."); if ((period >= 0) && (period > slash)) {
path = path.substring(0, period);
} return (path);
}
protected String processPath(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
String path; // Set per request the original path for postback forms
if (request.getAttribute(Globals.ORIGINAL_URI_KEY) == null) {
request.setAttribute(Globals.ORIGINAL_URI_KEY, request.getServletPath());
} // For prefix matching, match on the path info (if any)
path = (String) request.getAttribute(INCLUDE_PATH_INFO); if (path == null) {
path = request.getPathInfo();
} if ((path != null) && (path.length() > 0)) {
return (path);
} // For extension matching, strip the module prefix and extension
path = (String) request.getAttribute(INCLUDE_SERVLET_PATH); if (path == null) {
path = request.getServletPath();
} String prefix = moduleConfig.getPrefix(); if (!path.startsWith(prefix)) {
String msg = getInternal().getMessage("processPath"); log.error(msg + " " + request.getRequestURI());
response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); return null;
} path = path.substring(prefix.length()); int slash = path.lastIndexOf("/");
int period = path.lastIndexOf("."); if ((period >= 0) && (period > slash)) {
path = path.substring(0, period);
} return (path);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货