当前位置: 首页>>代码示例>>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;未经允许,请勿转载。