本文整理汇总了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);
}
}
}
}
示例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());
}
}
示例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);
}
}
示例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());
}
示例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());
}