String templatePath = requestUrlToTemplatePath(request);
/** * Special dispatch info is included when the request contains the attribute {@link * ContainerConstants#DISPATCH_URI_PROTOCOL}. For example this value is 'classpath:' or 'jcr:' or 'webfile:' to * load a template from a classpath or repository */ @Override protected String requestUrlToTemplatePath(HttpServletRequest request) throws ServletException { String path = super.requestUrlToTemplatePath(request); if (request.getAttribute(ContainerConstants.DISPATCH_URI_PROTOCOL) != null) { path = request.getAttribute(ContainerConstants.DISPATCH_URI_PROTOCOL) + path; } return path; }
protected String requestUrlToTemplatePath(HttpServletRequest request) throws ServletException { String templatePath = super.requestUrlToTemplatePath(request); if (templatePath != null && !"".equals(templatePath) && REWRITE_ARRAYS != null && REWRITE_ARRAYS.size() > 0) { // 计算rewrite for (Object object : REWRITE_ARRAYS) { JSONObject rewrite = (JSONObject) object; Pattern p = Pattern.compile(rewrite.getString("url")); Matcher m = p.matcher(templatePath); if (m.find()) { for (int i = 0; i <= m.groupCount(); i++) { request.setAttribute("rewriteParams" + i, m.group(i)); } request.setAttribute("rewriteName", rewrite.getString("name")); return rewrite.getString("page"); } } } if (!templatePath.endsWith(".html")) { templatePath += ".html"; } return templatePath; } }
String path = requestUrlToTemplatePath(request);
String templatePath = requestUrlToTemplatePath(request);
String templatePath = requestUrlToTemplatePath(request);