Inject UriComponentsBuilder relative to webapp root

Issue: SPR-16813
This commit is contained in:
Rossen Stoyanchev
2018-05-11 09:52:02 -04:00
parent 9179a4fa30
commit fd36af6fcf
2 changed files with 7 additions and 3 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.web.reactive.result.method.annotation;
import java.net.URI;
import java.time.ZoneId;
import java.util.Locale;
import java.util.TimeZone;
@@ -109,7 +110,8 @@ public class ServerWebExchangeArgumentResolver extends HandlerMethodArgumentReso
return timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault();
}
else if (UriBuilder.class == paramType || UriComponentsBuilder.class == paramType) {
return UriComponentsBuilder.fromHttpRequest(exchange.getRequest());
URI uri = exchange.getRequest().getURI();
return UriComponentsBuilder.fromUri(uri).replacePath(null).replaceQuery(null);
}
else {
// should never happen...