本文整理匯總了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);
}
示例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");
}
}
示例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>"));
}
示例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>"));
}
示例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");
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例12: getFlashMap
import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Override
public FlashMap getFlashMap() {
return RequestContextUtils.getOutputFlashMap(mockRequest);
}
示例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);
}
示例14: getFlashMap
import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
public FlashMap getFlashMap() {
return RequestContextUtils.getOutputFlashMap(mockRequest);
}
示例15: currentRequestFlashMap
import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
private FlashMap currentRequestFlashMap() {
return RequestContextUtils.getOutputFlashMap(this.request);
}