Remove the few remaining usages of UriTemplate

Also update Javadoc of UriTemplate to point to UriComponentsBuilder and
UriBuilderFactory as more flexible options.

See gh-24094
This commit is contained in:
Rossen Stoyanchev
2019-11-28 11:28:49 +00:00
parent df2ed75df0
commit b44daa8b71
7 changed files with 38 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,8 @@ import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.support.BindStatus;
import org.springframework.web.servlet.support.RequestContext;
import org.springframework.web.util.UriTemplate;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
/**
* Dummy request context used for FreeMarker macro tests.
@@ -140,8 +141,8 @@ public class DummyMacroRequestContext {
* @see org.springframework.web.servlet.support.RequestContext#getContextUrl(String, Map)
*/
public String getContextUrl(String relativeUrl, Map<String,String> params) {
UriTemplate template = new UriTemplate(relativeUrl);
return getContextPath() + template.expand(params).toASCIIString();
UriComponents uric = UriComponentsBuilder.fromUriString(relativeUrl).buildAndExpand(params);
return getContextPath() + uric.toUri().toASCIIString();
}
/**