Java Code Examples for org.springframework.web.util.UrlPathHelper#getRequestUri()

The following examples show how to use org.springframework.web.util.UrlPathHelper#getRequestUri() . 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: ResourceUrlEncodingFilter.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void initLookupPath(ResourceUrlProvider urlProvider) {
	this.resourceUrlProvider = urlProvider;
	if (this.indexLookupPath == null) {
		UrlPathHelper pathHelper = this.resourceUrlProvider.getUrlPathHelper();
		String requestUri = pathHelper.getRequestUri(this);
		String lookupPath = pathHelper.getLookupPathForRequest(this);
		this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
		Assert.isTrue(this.indexLookupPath != -1, () ->
				"Failed to find lookupPath '" + lookupPath + "' within requestUri '" + requestUri + ". " +
				"Does the path have invalid encoded characters " +
						"for characterEncoding=" + getRequest().getCharacterEncoding() + "?");
		this.prefixLookupPath = requestUri.substring(0, this.indexLookupPath);
		if ("/".equals(lookupPath) && !"/".equals(requestUri)) {
			String contextPath = pathHelper.getContextPath(this);
			if (requestUri.equals(contextPath)) {
				this.indexLookupPath = requestUri.length();
				this.prefixLookupPath = requestUri;
			}
		}
	}
}
 
Example 2
Source File: ResourceUrlEncodingFilter.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void initLookupPath(ResourceUrlProvider urlProvider) {
	this.resourceUrlProvider = urlProvider;
	if (this.indexLookupPath == null) {
		UrlPathHelper pathHelper = this.resourceUrlProvider.getUrlPathHelper();
		String requestUri = pathHelper.getRequestUri(this);
		String lookupPath = pathHelper.getLookupPathForRequest(this);
		this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
		this.prefixLookupPath = requestUri.substring(0, this.indexLookupPath);
		if ("/".equals(lookupPath) && !"/".equals(requestUri)) {
			String contextPath = pathHelper.getContextPath(this);
			if (requestUri.equals(contextPath)) {
				this.indexLookupPath = requestUri.length();
				this.prefixLookupPath = requestUri;
			}
		}
	}
}
 
Example 3
Source File: ResourceUrlEncodingFilter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void initLookupPath(ResourceUrlProvider urlProvider) {
	if (this.indexLookupPath == null) {
		UrlPathHelper pathHelper = urlProvider.getUrlPathHelper();
		String requestUri = pathHelper.getRequestUri(this.request);
		String lookupPath = pathHelper.getLookupPathForRequest(this.request);
		this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
		this.prefixLookupPath = requestUri.substring(0, this.indexLookupPath);

		if ("/".equals(lookupPath) && !"/".equals(requestUri)) {
			String contextPath = pathHelper.getContextPath(this.request);
			if (requestUri.equals(contextPath)) {
				this.indexLookupPath = requestUri.length();
				this.prefixLookupPath = requestUri;
			}
		}
	}
}
 
Example 4
Source File: ResourceUrlProvider.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private int getLookupPathIndex(HttpServletRequest request) {
	UrlPathHelper pathHelper = getUrlPathHelper();
	String requestUri = pathHelper.getRequestUri(request);
	String lookupPath = this.urlPathHelper.getLookupPathForRequest(request, HandlerMapping.LOOKUP_PATH);
	return requestUri.indexOf(lookupPath);
}
 
Example 5
Source File: ResourceUrlProvider.java    From java-technology-stack with MIT License 4 votes vote down vote up
private int getLookupPathIndex(HttpServletRequest request) {
	UrlPathHelper pathHelper = getUrlPathHelper();
	String requestUri = pathHelper.getRequestUri(request);
	String lookupPath = pathHelper.getLookupPathForRequest(request);
	return requestUri.indexOf(lookupPath);
}
 
Example 6
Source File: ResourceUrlProvider.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private int getLookupPathIndex(HttpServletRequest request) {
	UrlPathHelper pathHelper = getUrlPathHelper();
	String requestUri = pathHelper.getRequestUri(request);
	String lookupPath = pathHelper.getLookupPathForRequest(request);
	return requestUri.indexOf(lookupPath);
}