Include only path in <spring:mvcUrl>

Issue: SPR-13045
This commit is contained in:
Rossen Stoyanchev
2015-05-20 17:06:47 -04:00
parent af67bd944b
commit ad4c8795ae
2 changed files with 8 additions and 2 deletions

View File

@@ -740,7 +740,7 @@ public class MvcUriComponentsBuilder {
public MethodArgumentBuilder(UriComponentsBuilder baseUrl, Class<?> controllerType, Method method) {
Assert.notNull(controllerType, "'controllerType' is required");
Assert.notNull(method, "'method' is required");
this.baseUrl = baseUrl;
this.baseUrl = (baseUrl != null ? baseUrl : initBaseUrl());
this.controllerType = controllerType;
this.method = method;
this.argumentValues = new Object[method.getParameterTypes().length];
@@ -749,11 +749,17 @@ public class MvcUriComponentsBuilder {
}
}
private static UriComponentsBuilder initBaseUrl() {
UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentServletMapping();
return UriComponentsBuilder.fromPath(builder.build().getPath());
}
/**
* @deprecated as of 4.2 deprecated in favor of alternative constructors
* that accept the controllerType.
*/
@Deprecated
@SuppressWarnings("unused")
public MethodArgumentBuilder(Method method) {
this(method.getDeclaringClass(), method);
}