Example usage for org.springframework.web.servlet FlashMap getTargetRequestParams

List of usage examples for org.springframework.web.servlet FlashMap getTargetRequestParams

Introduction

In this page you can find the example usage for org.springframework.web.servlet FlashMap getTargetRequestParams.

Prototype

public MultiValueMap<String, String> getTargetRequestParams() 

Source Link

Document

Return the parameters identifying the target request, or an empty map.

Usage

From source file:org.springframework.web.servlet.support.AbstractFlashMapManager.java

/**
 * Whether the given FlashMap matches the current request.
 * Uses the expected request path and query parameters saved in the FlashMap.
 *//*from   w w w.j  a v  a2  s. c  o  m*/
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {
    String expectedPath = flashMap.getTargetRequestPath();
    if (expectedPath != null) {
        String requestUri = getUrlPathHelper().getOriginatingRequestUri(request);
        if (!requestUri.equals(expectedPath) && !requestUri.equals(expectedPath + "/")) {
            return false;
        }
    }
    MultiValueMap<String, String> actualParams = getOriginatingRequestParams(request);
    MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
    for (String expectedName : expectedParams.keySet()) {
        List<String> actualValues = actualParams.get(expectedName);
        if (actualValues == null) {
            return false;
        }
        for (String expectedValue : expectedParams.get(expectedName)) {
            if (!actualValues.contains(expectedValue)) {
                return false;
            }
        }
    }
    return true;
}

From source file:org.springframework.web.servlet.support.DefaultFlashMapManager.java

/**
 * Whether the given FlashMap matches the current request.
 * The default implementation uses the target request path and query params 
 * saved in the FlashMap./*w  w w . j a v  a 2 s .  c  om*/
 */
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {
    if (flashMap.getTargetRequestPath() != null) {
        String requestUri = this.urlPathHelper.getOriginatingRequestUri(request);
        if (!requestUri.equals(flashMap.getTargetRequestPath())
                && !requestUri.equals(flashMap.getTargetRequestPath() + "/")) {
            return false;
        }
    }
    MultiValueMap<String, String> targetParams = flashMap.getTargetRequestParams();
    for (String paramName : targetParams.keySet()) {
        for (String targetValue : targetParams.get(paramName)) {
            if (!ObjectUtils.containsElement(request.getParameterValues(paramName), targetValue)) {
                return false;
            }
        }
    }
    return true;
}