List of usage examples for org.springframework.web.servlet FlashMap getTargetRequestPath
@Nullable
public String getTargetRequestPath()
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 www. j a va 2s . co 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.AbstractFlashMapManager.java
@Override public final void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest request, HttpServletResponse response) {/*from w ww . j av a2 s . c o m*/ if (CollectionUtils.isEmpty(flashMap)) { return; } String path = decodeAndNormalizePath(flashMap.getTargetRequestPath(), request); flashMap.setTargetRequestPath(path); if (logger.isDebugEnabled()) { logger.debug("Saving FlashMap=" + flashMap); } flashMap.startExpirationPeriod(getFlashMapTimeout()); Object mutex = getFlashMapsMutex(request); if (mutex != null) { synchronized (mutex) { List<FlashMap> allFlashMaps = retrieveFlashMaps(request); allFlashMaps = (allFlashMaps != null ? allFlashMaps : new CopyOnWriteArrayList<>()); allFlashMaps.add(flashMap); updateFlashMaps(allFlashMaps, request, response); } } else { List<FlashMap> allFlashMaps = retrieveFlashMaps(request); allFlashMaps = (allFlashMaps != null ? allFlashMaps : new LinkedList<>()); allFlashMaps.add(flashMap); updateFlashMaps(allFlashMaps, request, response); } }
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.//from w w w . j a v a 2 s.c o m */ 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; }
From source file:org.springframework.web.servlet.support.DefaultFlashMapManager.java
/** * Update a FlashMap before it is stored in the HTTP Session. * <p>The default implementation starts the expiration period and ensures the * target request path is decoded and normalized if it is relative. * @param flashMap the flash map to be saved * @param request the current request//from w w w . java 2 s .c om */ protected void onSaveFlashMap(FlashMap flashMap, HttpServletRequest request) { String targetPath = flashMap.getTargetRequestPath(); flashMap.setTargetRequestPath(decodeAndNormalizePath(targetPath, request)); flashMap.startExpirationPeriod(this.flashTimeout); }