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


Java WebUtils.isIncludeRequest方法代碼示例

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


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

示例1: doService

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
/**
 * Exposes the DispatcherServlet-specific request attributes and delegates to {@link #doDispatch}
 * for the actual dispatching.
 */
@Override
protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {
	if (logger.isDebugEnabled()) {
		String resumed = WebAsyncUtils.getAsyncManager(request).hasConcurrentResult() ? " resumed" : "";
		logger.debug("DispatcherServlet with name '" + getServletName() + "'" + resumed +
				" processing " + request.getMethod() + " request for [" + getRequestUri(request) + "]");
	}

	// Keep a snapshot of the request attributes in case of an include,
	// to be able to restore the original attributes after the include.
	Map<String, Object> attributesSnapshot = null;
	if (WebUtils.isIncludeRequest(request)) {
		attributesSnapshot = new HashMap<String, Object>();
		Enumeration<?> attrNames = request.getAttributeNames();
		while (attrNames.hasMoreElements()) {
			String attrName = (String) attrNames.nextElement();
			if (this.cleanupAfterInclude || attrName.startsWith("org.springframework.web.servlet")) {
				attributesSnapshot.put(attrName, request.getAttribute(attrName));
			}
		}
	}

	// Make framework objects available to handlers and view objects.
	request.setAttribute(WEB_APPLICATION_CONTEXT_ATTRIBUTE, getWebApplicationContext());
	request.setAttribute(LOCALE_RESOLVER_ATTRIBUTE, this.localeResolver);
	request.setAttribute(THEME_RESOLVER_ATTRIBUTE, this.themeResolver);
	request.setAttribute(THEME_SOURCE_ATTRIBUTE, getThemeSource());

	FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(request, response);
	if (inputFlashMap != null) {
		request.setAttribute(INPUT_FLASH_MAP_ATTRIBUTE, Collections.unmodifiableMap(inputFlashMap));
	}
	request.setAttribute(OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
	request.setAttribute(FLASH_MAP_MANAGER_ATTRIBUTE, this.flashMapManager);

	try {
		doDispatch(request, response);
	}
	finally {
		if (!WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
			// Restore the original attribute snapshot, in case of an include.
			if (attributesSnapshot != null) {
				restoreAttributesAfterInclude(request, attributesSnapshot);
			}
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:52,代碼來源:DispatcherServlet.java

示例2: applyStatusIfPossible

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
private void applyStatusIfPossible(ServletWebRequest webRequest, HttpStatus status) {
	if (!WebUtils.isIncludeRequest(webRequest.getRequest())) {
		webRequest.getResponse().setStatus(status.value());
	}
}
 
開發者ID:reportportal,項目名稱:commons-rules,代碼行數:6,代碼來源:RestExceptionHandler.java

示例3: applyStatusCodeIfPossible

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
/**
 * Apply the specified HTTP status code to the given response, if possible (that is,
 * if not executing within an include request).
 * @param request current HTTP request
 * @param response current HTTP response
 * @param statusCode the status code to apply
 * @see #determineStatusCode
 * @see #setDefaultStatusCode
 * @see HttpServletResponse#setStatus
 */
protected void applyStatusCodeIfPossible(HttpServletRequest request, HttpServletResponse response, int statusCode) {
	if (!WebUtils.isIncludeRequest(request)) {
		if (logger.isDebugEnabled()) {
			logger.debug("Applying HTTP status code " + statusCode);
		}
		response.setStatus(statusCode);
		request.setAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE, statusCode);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:20,代碼來源:SimpleMappingExceptionResolver.java

示例4: useInclude

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
/**
 * Determine whether to use RequestDispatcher's {@code include} or
 * {@code forward} method.
 * <p>Performs a check whether an include URI attribute is found in the request,
 * indicating an include request, and whether the response has already been committed.
 * In both cases, an include will be performed, as a forward is not possible anymore.
 * @param request current HTTP request
 * @param response current HTTP response
 * @return {@code true} for include, {@code false} for forward
 * @see javax.servlet.RequestDispatcher#forward
 * @see javax.servlet.RequestDispatcher#include
 * @see javax.servlet.ServletResponse#isCommitted
 * @see org.springframework.web.util.WebUtils#isIncludeRequest
 */
protected boolean useInclude(HttpServletRequest request, HttpServletResponse response) {
	return (this.alwaysInclude || WebUtils.isIncludeRequest(request) || response.isCommitted());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:InternalResourceView.java

示例5: useInclude

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
/**
 * Determine whether to use RequestDispatcher's {@code include} or
 * {@code forward} method.
 * <p>Performs a check whether an include URI attribute is found in the request,
 * indicating an include request, and whether the response has already been committed.
 * In both cases, an include will be performed, as a forward is not possible anymore.
 * @param request current HTTP request
 * @param response current HTTP response
 * @return {@code true} for include, {@code false} for forward
 * @see javax.servlet.RequestDispatcher#forward
 * @see javax.servlet.RequestDispatcher#include
 * @see javax.servlet.ServletResponse#isCommitted
 * @see org.springframework.web.util.WebUtils#isIncludeRequest
 */
protected boolean useInclude(HttpServletRequest request, HttpServletResponse response) {
	return (WebUtils.isIncludeRequest(request) || response.isCommitted());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:ServletForwardingController.java


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