Java Code Examples for org.springframework.web.servlet.support.RequestContextUtils#saveOutputFlashMap()

The following examples show how to use org.springframework.web.servlet.support.RequestContextUtils#saveOutputFlashMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpEntityMethodProcessor.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void saveFlashAttributes(ModelAndViewContainer mav, NativeWebRequest request, String location) {
	mav.setRedirectModelScenario(true);
	ModelMap model = mav.getModel();
	if (model instanceof RedirectAttributes) {
		Map<String, ?> flashAttributes = ((RedirectAttributes) model).getFlashAttributes();
		if (!CollectionUtils.isEmpty(flashAttributes)) {
			HttpServletRequest req = request.getNativeRequest(HttpServletRequest.class);
			HttpServletResponse res = request.getNativeResponse(HttpServletResponse.class);
			if (req != null) {
				RequestContextUtils.getOutputFlashMap(req).putAll(flashAttributes);
				if (res != null) {
					RequestContextUtils.saveOutputFlashMap(location, req, res);
				}
			}
		}
	}
}
 
Example 2
Source File: HttpEntityMethodProcessor.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void saveFlashAttributes(ModelAndViewContainer mav, NativeWebRequest request, String location) {
	mav.setRedirectModelScenario(true);
	ModelMap model = mav.getModel();
	if (model instanceof RedirectAttributes) {
		Map<String, ?> flashAttributes = ((RedirectAttributes) model).getFlashAttributes();
		if (!CollectionUtils.isEmpty(flashAttributes)) {
			HttpServletRequest req = request.getNativeRequest(HttpServletRequest.class);
			HttpServletResponse res = request.getNativeResponse(HttpServletResponse.class);
			if (req != null) {
				RequestContextUtils.getOutputFlashMap(req).putAll(flashAttributes);
				if (res != null) {
					RequestContextUtils.saveOutputFlashMap(location, req, res);
				}
			}
		}
	}
}
 
Example 3
Source File: RedirectView.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * 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);
	targetUrl = updateTargetUrl(targetUrl, model, request, response);

	// Save flash attributes
	RequestContextUtils.saveOutputFlashMap(targetUrl, request, response);

	// Redirect
	sendRedirect(request, response, targetUrl, this.http10Compatible);
}
 
Example 4
Source File: RedirectView.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 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);
	targetUrl = updateTargetUrl(targetUrl, model, request, response);

	// Save flash attributes
	RequestContextUtils.saveOutputFlashMap(targetUrl, request, response);

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