Spring Framework UrlPathHelper - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework UrlPathHelper class.

This code example shows how to use the following methods:getRequestUri
	/** 
	 * Create a new NoSuchRequestHandlingMethodException for the given request. 
	 * @param request the offending HTTP request 
	 */ 
	public NoSuchRequestHandlingMethodException(HttpServletRequest request) { 
		this(new UrlPathHelper().getRequestUri(request), request.getMethod(), request.getParameterMap()); 
	} 
 
	/** 
	 * Create a new NoSuchRequestHandlingMethodException. 
	 * @param urlPath the request URI that has been used for handler lookup 
	 * @param method the HTTP request method of the request 
	 * @param parameterMap the request's parameters as map 
	 */ 
	public NoSuchRequestHandlingMethodException(String urlPath, String method, Map<String, String[]> parameterMap) { 
		super("No matching handler method found for servlet request: path '" + urlPath + 
				"', method '" + method + "', parameters " + StylerUtils.style(parameterMap)); 
	} 
 
	/** 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getOriginatingContextPath, getOriginatingRequestUri, getPathWithinApplication, setDefaultEncoding, setUrlDecode
{ 
 
    public String getRequestPathFromHttpRequest( HttpServletRequest req ) 
    { 
 
        UrlPathHelper urlPathHelper = new UrlPathHelper(); 
        urlPathHelper.setUrlDecode( true ); 
        urlPathHelper.setDefaultEncoding( "UTF-8" ); 
 
        String path = urlPathHelper.getPathWithinApplication( req ); 
 
        if ( !hasSitePathPrefix( path ) ) 
        { 
            path = urlPathHelper.getOriginatingRequestUri( req ); 
            String contextPath = urlPathHelper.getOriginatingContextPath( req ); 
            if ( contextPath != null && path.startsWith( contextPath ) ) 
            { 
                path = path.substring( contextPath.length() ); 
            } 
        } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 * @author Rossen Stoyanchev 
 * @since 3.1 
 */ 
public class ServletCookieValueMethodArgumentResolver extends AbstractCookieValueMethodArgumentResolver { 
 
	private UrlPathHelper urlPathHelper = new UrlPathHelper(); 
 
 
	public ServletCookieValueMethodArgumentResolver(ConfigurableBeanFactory beanFactory) { 
		super(beanFactory); 
	} 
 
 
	public void setUrlPathHelper(UrlPathHelper urlPathHelper) { 
		this.urlPathHelper = urlPathHelper; 
	} 
 
 
	@Override 
	protected Object resolveName(String cookieName, MethodParameter parameter, NativeWebRequest webRequest) throws Exception { 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
public abstract class AbstractUrlMethodNameResolver implements MethodNameResolver { 
 
	/** Logger available to subclasses */ 
	protected final Log logger = LogFactory.getLog(getClass()); 
 
	private UrlPathHelper urlPathHelper = new UrlPathHelper(); 
 
 
	/** 
	 * Set if URL lookup should always use full path within current servlet 
	 * context. Else, the path within the current servlet mapping is used 
	 * if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml). 
	 * Default is "false". 
	 * @see org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath 
	 */ 
	public void setAlwaysUseFullPath(boolean alwaysUseFullPath) { 
		this.urlPathHelper.setAlwaysUseFullPath(alwaysUseFullPath); 
	} 
 
	/** 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setUrlDecode
	private static final boolean JAF_PRESENT = ClassUtils.isPresent("javax.activation.FileTypeMap", 
					PathExtensionContentNegotiationStrategy.class.getClassLoader()); 
 
	private static final Log logger = LogFactory.getLog(PathExtensionContentNegotiationStrategy.class); 
 
	private static final UrlPathHelper urlPathHelper = new UrlPathHelper(); 
 
	static { 
		urlPathHelper.setUrlDecode(false); 
	} 
 
	private boolean useJaf = JAF_PRESENT; 
 
	private boolean ignoreUnknownExtensions = true; 
 
 
	/** 
	 * Create an instance with the given extension-to-MediaType lookup. 
	 * @throws IllegalArgumentException if a media type string cannot be parsed 
	 */ 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPathWithinServletMapping
		} 
		return builder; 
	} 
 
	/** 
	 * Prepare a builder from the host, port, scheme, and path of 
	 * an HttpServletRequest. 
	 */ 
	public static ServletUriComponentsBuilder fromRequestUri(HttpServletRequest request) { 
		ServletUriComponentsBuilder builder = fromRequest(request); 
		builder.pathFromRequest(request); 
		builder.replaceQuery(null); 
		return builder; 
	} 
 
	/** 
	 * Prepare a builder by copying the scheme, host, port, path, and 
	 * query string of an HttpServletRequest. 
	 */ 
	public static ServletUriComponentsBuilder fromRequest(HttpServletRequest request) { 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 * @see #setAlwaysUseFullPath 
 * @see #setUrlDecode 
 */ 
public abstract class AbstractUrlViewController extends AbstractController { 
 
	private UrlPathHelper urlPathHelper = new UrlPathHelper(); 
 
 
	/** 
	 * Set if URL lookup should always use full path within current servlet 
	 * context. Else, the path within the current servlet mapping is used 
	 * if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml). 
	 * Default is "false". 
	 * @see org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath 
	 */ 
	public void setAlwaysUseFullPath(boolean alwaysUseFullPath) { 
		this.urlPathHelper.setAlwaysUseFullPath(alwaysUseFullPath); 
	} 
 
	/** 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
	private static final String EXTENSION_MAPPING_PATTERN = "*."; 
 
	private static final String PATH_MAPPING_PATTERN = "/*"; 
 
	private static final UrlPathHelper urlPathHelper = new UrlPathHelper(); 
 
	private final Filter delegate; 
 
	/** Patterns that require an exact match, e.g. "/test" */ 
	private final List<String> exactMatches = new ArrayList<String>(); 
 
	/** Patterns that require the URL to have a specific prefix, e.g. "/test/*" */ 
	private final List<String> startsWithMatches = new ArrayList<String>(); 
 
	/** Patterns that require the request URL to have a specific suffix, e.g. "*.html" */ 
	private final List<String> endsWithMatches = new ArrayList<String>(); 
 
 
	/** 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getOriginatingQueryString, getOriginatingRequestUri, setDefaultEncoding
 
public class OriginalUrlResolver 
{ 
    public static String buildOriginalUrl( HttpServletRequest req ) 
    { 
        final UrlPathHelper urlPathHelper = new UrlPathHelper(); 
        urlPathHelper.setDefaultEncoding( "UTF-8" ); 
 
        final StringBuilder url = new StringBuilder(); 
        url.append( req.getScheme() ).append( "://" ); 
        url.append( req.getServerName() ); 
 
        final int serverPort = req.getServerPort(); 
        if ( serverPort != 80 ) 
        { 
            url.append( ":" ).append( serverPort ); 
        } 
 
        final String originatingUri = urlPathHelper.getOriginatingRequestUri( req ); 
        url.append( originatingUri ); 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	} 
 
 
	private static class MyHandlerMethodMapping extends AbstractHandlerMethodMapping<String> { 
 
		private UrlPathHelper pathHelper = new UrlPathHelper(); 
 
		private PathMatcher pathMatcher = new AntPathMatcher(); 
 
		@Override 
		protected String getMatchingMapping(String pattern, HttpServletRequest request) { 
			String lookupPath = pathHelper.getLookupPathForRequest(request); 
			return pathMatcher.match(pattern, lookupPath) ? pattern : null; 
		} 
 
		@Override 
		protected String getMappingForMethod(Method method, Class<?> handlerType) { 
			String methodName = method.getName(); 
			return methodName.startsWith("handler") ? methodName : null; 
		} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework UrlPathHelper Methods: