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