コード例 #1
0
  /** The method to replace http:// URLs to https:// */
  protected void sendRedirect(
      HttpServletRequest request,
      HttpServletResponse response,
      String targetUrl,
      boolean http10Compatible)
      throws IOException {

    if (secure && targetUrl.startsWith("http://")) {
      targetUrl = StringUtils.replaceOnce(targetUrl, "http://", "https://");
    }

    if (!targetUrl.startsWith("http")) {
      // Get the secure URL and build complete URL
      StringBuffer sb = new StringBuffer();

      if (!ignoreContext) {
        sb.append(request.getServletPath());
      }
      sb.append("/");
      sb.append(targetUrl);
      targetUrl = sb.toString();
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Redirecting to URL : [" + targetUrl + "]");
    }

    super.sendRedirect(request, response, targetUrl, http10Compatible);
  }
コード例 #2
0
  /**
   * Convert model to request parameters and redirect to the given URL.
   *
   * @see #appendQueryProperties
   * @see #sendRedirect
   */
  @Override
  protected void renderMergedOutputModel(
      Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    String targetUrl = createTargetUrl(model, request);

    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    if (!CollectionUtils.isEmpty(flashMap)) {
      String targetPath = WebUtils.extractUrlPath(targetUrl.toString());
      flashMap.setTargetRequestPath(targetPath);
      if (this.exposeModelAttributes) {
        flashMap.addTargetRequestParams(model);
      }
    }

    sendRedirect(request, response, targetUrl.toString(), this.http10Compatible);
  }