Java Code Examples for org.springframework.web.servlet.HandlerMapping#PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
The following examples show how to use
org.springframework.web.servlet.HandlerMapping#PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceHttpRequestHandler.java From spring-analysis-note with MIT License | 6 votes |
@Nullable 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)) { return null; } if (isInvalidEncodedPath(path)) { return null; } Assert.notNull(this.resolverChain, "ResourceResolverChain not initialized."); Assert.notNull(this.transformerChain, "ResourceTransformerChain not initialized."); Resource resource = this.resolverChain.resolveResource(request, path, getLocations()); if (resource != null) { resource = this.transformerChain.transform(request, resource); } return resource; }
Example 2
Source File: ResourceHttpRequestHandler.java From java-technology-stack with MIT License | 6 votes |
@Nullable 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)) { return null; } if (isInvalidEncodedPath(path)) { return null; } Assert.notNull(this.resolverChain, "ResourceResolverChain not initialized."); Assert.notNull(this.transformerChain, "ResourceTransformerChain not initialized."); Resource resource = this.resolverChain.resolveResource(request, path, getLocations()); if (resource != null) { resource = this.transformerChain.transform(request, resource); } return resource; }
Example 3
Source File: ResourceHttpRequestHandler.java From lams with GNU General Public License v2.0 | 5 votes |
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; }
Example 4
Source File: ResourceHttpRequestHandler.java From spring4-understanding with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: StaticAssetsRequestHandler.java From engine with GNU General Public License v3.0 | 5 votes |
protected String getPath(HttpServletRequest request, SiteContext siteContext) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (StringUtils.isEmpty(path)) { throw new IllegalStateException("Required request attribute '" + HandlerMapping .PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE + "' is not set"); } if (StringUtils.isNotEmpty(staticAssetsPath)) { return UrlUtils.concat(staticAssetsPath, path); } else { return UrlUtils.concat(siteContext.getStaticAssetsPath(), path); } }
Example 6
Source File: RemoteAssetsRequestHandler.java From engine with GNU General Public License v3.0 | 5 votes |
protected String getPath(HttpServletRequest request) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (StringUtils.isNotEmpty(path)) { return !path.startsWith("/") ? "/" + path : path; } else { throw new IllegalStateException("Required request attribute '" + HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE + "' is not set"); } }
Example 7
Source File: RestScriptsController.java From engine with GNU General Public License v3.0 | 5 votes |
protected String getServiceUrl(HttpServletRequest request) { String pathWithinHandlerMappingAttr = HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE; String url = (String) request.getAttribute(pathWithinHandlerMappingAttr); if (StringUtils.isEmpty(url)) { throw new IllegalStateException( "Required request attribute '" + pathWithinHandlerMappingAttr + "' is not set"); } return url; }
Example 8
Source File: SockJsHttpRequestHandler.java From spring-analysis-note with MIT License | 4 votes |
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); }
Example 9
Source File: SockJsHttpRequestHandler.java From java-technology-stack with MIT License | 4 votes |
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); }
Example 10
Source File: SockJsHttpRequestHandler.java From spring4-understanding with Apache License 2.0 | 4 votes |
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); }
Example 11
Source File: SpaceKeyHandshakeInterceptor.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 4 votes |
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; }