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


Java HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE屬性代碼示例

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


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

示例1: getResource

protected Resource getResource(HttpServletRequest request) throws IOException {
	String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
	if (path == null) {
		throw new IllegalStateException("Required request attribute '" +
				HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE + "' is not set");
	}
	path = processPath(path);
	if (!StringUtils.hasText(path) || isInvalidPath(path)) {
		if (logger.isTraceEnabled()) {
			logger.trace("Ignoring invalid resource path [" + path + "]");
		}
		return null;
	}
	if (path.contains("%")) {
		try {
			// Use URLDecoder (vs UriUtils) to preserve potentially decoded UTF-8 chars
			if (isInvalidPath(URLDecoder.decode(path, "UTF-8"))) {
				if (logger.isTraceEnabled()) {
					logger.trace("Ignoring invalid resource path with escape sequences [" + path + "].");
				}
				return null;
			}
		}
		catch (IllegalArgumentException ex) {
			// ignore
		}
	}
	ResourceResolverChain resolveChain = new DefaultResourceResolverChain(getResourceResolvers());
	Resource resource = resolveChain.resolveResource(request, path, getLocations());
	if (resource == null || getResourceTransformers().isEmpty()) {
		return resource;
	}
	ResourceTransformerChain transformChain =
			new DefaultResourceTransformerChain(resolveChain, getResourceTransformers());
	resource = transformChain.transform(request, resource);
	return resource;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:37,代碼來源:ResourceHttpRequestHandler.java

示例2: getResource

protected Resource getResource(String path, HttpServletRequest request, HttpServletResponse response) throws IOException {
	if (path == null) {
		throw new IllegalStateException("Required request attribute '" + HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE + "' is not set");
	}
	path = processPath(path);
	if (!StringUtils.hasText(path) || isInvalidPath(path)) {
		if (logger.isTraceEnabled()) {
			logger.trace("Ignoring invalid resource path [" + path + "]");
		}
		return null;
	}
	if (path.contains("%")) {
		try {
			// Use URLDecoder (vs UriUtils) to preserve potentially decoded UTF-8 chars
			if (isInvalidPath(URLDecoder.decode(path, "UTF-8"))) {
				if (logger.isTraceEnabled()) {
					logger.trace("Ignoring invalid resource path with escape sequences [" + path + "].");
				}
				return null;
			}
		}
		catch (IllegalArgumentException ex) {
			// ignore
		}
	}
	if (resourceHandlers != null) {
		for (ResourceHandler handler : resourceHandlers) {
			// logger.info("path:" + path);
			Resource resource = handler.doHandler(path, request, response);
			if (resource != null && resource.exists()) {
				// logger.info("handler:" + handler.getClass().getSimpleName() + " resource:" + resource.exists());
				return resource;
			}
		}
	}
	return null;
}
 
開發者ID:tanhaichao,項目名稱:leopard,代碼行數:37,代碼來源:ResourcesDispatcherServlet.java

示例3: getSockJsPath

private String getSockJsPath(HttpServletRequest servletRequest) {
	String attribute = HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE;
	String path = (String) servletRequest.getAttribute(attribute);
	return (path.length() > 0 && path.charAt(0) != '/' ? "/" + path : path);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:SockJsHttpRequestHandler.java

示例4: getSockJsPath

private String getSockJsPath(HttpServletRequest servletRequest) {
    String attribute = HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE;
    String path = (String) servletRequest.getAttribute(attribute);
    return ((path.length() > 0) && (path.charAt(0) != '/')) ? "/" + path : path;
}
 
開發者ID:Coding,項目名稱:WebIDE-Backend,代碼行數:5,代碼來源:SpaceKeyHandshakeInterceptor.java


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