當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestContextUtils.getOutputFlashMap方法代碼示例

本文整理匯總了Java中org.springframework.web.servlet.support.RequestContextUtils.getOutputFlashMap方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestContextUtils.getOutputFlashMap方法的具體用法?Java RequestContextUtils.getOutputFlashMap怎麽用?Java RequestContextUtils.getOutputFlashMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.servlet.support.RequestContextUtils的用法示例。


在下文中一共展示了RequestContextUtils.getOutputFlashMap方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderMergedOutputModel

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
/**
 * 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);

	FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
	if (!CollectionUtils.isEmpty(flashMap)) {
		UriComponents uriComponents = UriComponentsBuilder.fromUriString(targetUrl).build();
		flashMap.setTargetRequestPath(uriComponents.getPath());
		flashMap.addTargetRequestParams(uriComponents.getQueryParams());
		FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request);
		if (flashMapManager == null) {
			throw new IllegalStateException("FlashMapManager not found despite output FlashMap having been set");
		}
		flashMapManager.saveOutputFlashMap(flashMap, request, response);
	}

	sendRedirect(request, response, targetUrl, this.http10Compatible);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:27,代碼來源:RedirectView.java

示例2: handleAllExceptions

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@ExceptionHandler({Exception.class, RuntimeException.class})
public ModelAndView handleAllExceptions(Exception ex,
                                        HttpServletRequest request) {
    log.error(String.format("An unhandled error occurred on page %s.", request.getRequestURL()) ,ex);

    if (config.isDevOn()) {
        FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
        flashMap.put("exceptionName", ex.getClass().getSimpleName());
        flashMap.put("exception", ex.getMessage());

        StringWriter errors = new StringWriter();
        ex.printStackTrace(new PrintWriter(errors));
        flashMap.put("stackTrace", errors.toString());
    }
    return new ModelAndView("redirect:/error");
}
 
開發者ID:mattpwest,項目名稱:entelect-spring-webapp-template,代碼行數:17,代碼來源:GlobalExceptionControllerAdvice.java

示例3: save

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
/**
 * {@link PostBack} インスタンスを保存します。
 * @param postBack {@link PostBack} インスタンス
 */
public static void save(PostBack postBack) {
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    DispatchType dispatchType = getDispatchType(postBack.getException());
    switch (dispatchType) {
    case JSP:
        requestAttributes.setAttribute(PostBack.POST_BACK_ATTRIBUTE_KEY, postBack, RequestAttributes.SCOPE_REQUEST);
        break;
    case FORWARD:
        requestAttributes.setAttribute(PostBack.POST_BACK_ATTRIBUTE_KEY, postBack, RequestAttributes.SCOPE_REQUEST);
        break;
    case REDIRECT:
        PostBackManager instance = (PostBackManager) requestAttributes.getAttribute(STORE_KEY_TO_REQUEST, RequestAttributes.SCOPE_REQUEST);
        FlashMap flashMap = RequestContextUtils.getOutputFlashMap(instance.request);
        flashMap.put(PostBack.POST_BACK_ATTRIBUTE_KEY, postBack);
        break;
    default:
        throw new InternalException(PostBackManager.class, "E-POSTBACK#0001");
    }
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:24,代碼來源:PostBackManager.java

示例4: MessageContext

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Test
public void インフォメーションメッセージがリクエストとフラッシュスコープにセットされ出力される() throws Exception {

    MessageContext context = new MessageContext(request);
    context.saveInformationMessageToRequest("I-JX_INFORMATIONS_TAG_TEST#0001");
    context.saveInformationMessageToFlash("I-JX_INFORMATIONS_TAG_TEST#0002");
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    request.setAttribute(MessageContext.INFORMATION_MESSAGE_KEY_TO_FLASH, flashMap.get(MessageContext.INFORMATION_MESSAGE_KEY_TO_FLASH));
    JseInformationsTag tag = new JseInformationsTag();
    tag.setJspContext(page);
    tag.doTag();

    assertThat(response.getContentAsString(), is("<div class=\"jfw_messages\">"
        + "<p class=\"jfw_msg_style\">I-JX_INFORMATIONS_TAG_TEST#0001</p>"
        + "<p class=\"jfw_msg_style\">I-JX_INFORMATIONS_TAG_TEST#0002</p></div>"));
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:17,代碼來源:JseInformationsTagTest.java

示例5: MessageContext

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Test
public void エラーメッセージがリクエストとフラッシュスコープにセットされ出力される() throws Exception {

    MessageContext context = new MessageContext(request);
    context.saveErrorMessageToRequest("E-JX_ERRORS_TAG_TEST#0001");
    context.saveErrorMessageToFlash("E-JX_ERRORS_TAG_TEST#0002");
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    request.setAttribute(MessageContext.ERROR_MESSAGE_KEY_TO_FLASH, flashMap.get(MessageContext.ERROR_MESSAGE_KEY_TO_FLASH));
    JseErrorsTag tag = new JseErrorsTag();
    tag.setJspContext(page);
    tag.doTag();

    assertThat(response.getContentAsString(), is("<div class=\"jfw_messages\">"
            + "<p class=\"jfw_err_msg_style\">E-JX_ERRORS_TAG_TEST#0001</p>"
            + "<p class=\"jfw_err_msg_style\">E-JX_ERRORS_TAG_TEST#0002</p></div>"));
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:17,代碼來源:JseErrorsTagTest.java

示例6: handleEntityNotFound

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@ExceptionHandler(EntityNotFoundException.class)
public RedirectView handleEntityNotFound(EntityNotFoundException ex,
                                         HttpServletRequest request,
                                         HttpServletResponse response) {

    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    if (flashMap != null) {
        flashMap.put("error", ex.getMessage());
    }

    return new RedirectView("/admin/templates");
}
 
開發者ID:mattpwest,項目名稱:entelect-spring-webapp-template,代碼行數:13,代碼來源:EmailTemplateExceptionHandler.java

示例7: handleEntityNotFound

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@ExceptionHandler(EntityNotFoundException.class)
public RedirectView handleEntityNotFound(EntityNotFoundException ex,
                                         HttpServletRequest request,
                                         HttpServletResponse response) {

    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    if (flashMap != null) {
        flashMap.put("error", ex.getMessage());
    }

    return new RedirectView("/users");
}
 
開發者ID:mattpwest,項目名稱:entelect-spring-webapp-template,代碼行數:13,代碼來源:UserExceptionHandler.java

示例8: preHandle

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
    Object flashMapObj = RequestContextUtils.getOutputFlashMap(request);
    if (flashMapObj != null && !(flashMapObj instanceof FlashMap)) {
        // we need to create a FlashMap using the webapp classLoader
        FlashMap flashMapCopy = new FlashMap();
        flashMapCopy.putAll((Map<? extends String, ?>) flashMapObj);
        // then put it in the request
        SessionFlashMapManager sessionFlashMapManager = new SessionFlashMapManager();
        sessionFlashMapManager.saveOutputFlashMap(flashMapCopy, request, response);
    }

    return true;
}
 
開發者ID:motech,項目名稱:motech,代碼行數:15,代碼來源:FlashMapInterceptor.java

示例9: addRequestMessage

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
static void addRequestMessage(RequestMessage requestMessage, Model model, HttpServletRequest request) {
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    addListElement(flashMap, REQUEST_MESSAGES_KEY, requestMessage);
    if (model != null) {
        addListElement(model.asMap(), REQUEST_MESSAGES_KEY, requestMessage);
    }
}
 
開發者ID:solita,項目名稱:kansalaisaloite,代碼行數:8,代碼來源:BaseController.java

示例10: clearForFlash

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
private void clearForFlash(String key, String code, MessageType type) {
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    Messages messages = (Messages) flashMap.get(key);
    if (messages == null) return;
    
    if (Strings.isEmpty(code)) {
        flashMap.remove(key);
    } else {
        messages.remove(code);
        flashMap.put(key, messages);
    }
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:13,代碼來源:MessageContext.java

示例11: getMessageFromFlash

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
private List<String> getMessageFromFlash(String key) {
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    Messages messages = (Messages) flashMap.get(key);
    if (messages != null && !messages.isEmpty())
        return messages.getMessageList();

    return null;
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:9,代碼來源:MessageContextTest.java

示例12: getFlashMap

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Override
public FlashMap getFlashMap() {
	return RequestContextUtils.getOutputFlashMap(mockRequest);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:DefaultMvcResult.java

示例13: putResultInfo

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
protected void putResultInfo(String resultInfo, HttpServletRequest request) {
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    flashMap.put(RESULT_INFO_KEY, resultInfo);
}
 
開發者ID:solita,項目名稱:kansalaisaloite,代碼行數:5,代碼來源:TestDataController.java

示例14: getFlashMap

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
public FlashMap getFlashMap() {
	return RequestContextUtils.getOutputFlashMap(mockRequest);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:4,代碼來源:DefaultMvcResult.java

示例15: currentRequestFlashMap

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
private FlashMap currentRequestFlashMap() {
    return RequestContextUtils.getOutputFlashMap(this.request);
}
 
開發者ID:jeslopalo,項目名稱:flash-messages,代碼行數:4,代碼來源:FlashScopeStoreAccessor.java


注:本文中的org.springframework.web.servlet.support.RequestContextUtils.getOutputFlashMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。