Esempio n. 1
0
  /**
   * @param path
   * @param request
   * @param response
   * @param model
   * @return
   */
  public String getFilePath(
      String path, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
    String templatePath = path;
    int dirEndIndex = path.lastIndexOf("/");
    String lastPath = path.substring(dirEndIndex + 1, path.length());
    if (dirEndIndex > 0) {
      if (virifyNotNumber(lastPath)) {
        templatePath = path;
      } else {
        model.addAttribute("id", lastPath);
        templatePath = path.substring(0, dirEndIndex);
      }
    }
    model = (ModelMap) model.clone();

    Enumeration<String> parameters = request.getParameterNames();
    StringBuilder sb = new StringBuilder();
    while (parameters.hasMoreElements()) {
      String paramterName = parameters.nextElement();
      if (!paramterName.startsWith("spm")) {
        if (0 == sb.length()) {
          sb.append("/");
        } else {
          sb.append("&");
        }
        sb.append(paramterName);
        sb.append("=");
        sb.append(request.getParameter(paramterName));
        model.put(paramterName, request.getParameter(paramterName));
      }
    }
    path += sb.toString();
    model.put(KEY_INCLUDE, new IncludePage(request, response));
    model.put(CACHE_VAR, true);
    model.put(CONTEXT_BASE, request.getContextPath());
    return createCache(templatePath, path, model, response);
  }