/** * Create the target URL and, if necessary, pre-pend the contextPath, expand * URI template variables, append the current request query, and apply the * configured {@link #getRequestDataValueProcessor() * RequestDataValueProcessor}. */ protected final String createTargetUrl(Map<String, Object> model, ServerWebExchange exchange) { String url = getUrl(); Assert.state(url != null, "'url' not set"); ServerHttpRequest request = exchange.getRequest(); StringBuilder targetUrl = new StringBuilder(); if (isContextRelative() && url.startsWith("/")) { targetUrl.append(request.getPath().contextPath().value()); } targetUrl.append(url); if (StringUtils.hasText(targetUrl)) { Map<String, String> uriVars = getCurrentUriVariables(exchange); targetUrl = expandTargetUrlTemplate(targetUrl.toString(), model, uriVars); } if (isPropagateQuery()) { targetUrl = appendCurrentRequestQuery(targetUrl.toString(), request); } String result = targetUrl.toString(); RequestDataValueProcessor processor = getRequestDataValueProcessor(); return (processor != null ? processor.processUrl(exchange, result) : result); }
/** * Create the target URL and, if necessary, pre-pend the contextPath, expand * URI template variables, append the current request query, and apply the * configured {@link #getRequestDataValueProcessor() * RequestDataValueProcessor}. */ protected final String createTargetUrl(Map<String, Object> model, ServerWebExchange exchange) { StringBuilder targetUrl = new StringBuilder(); if (isContextRelative() && getUrl().startsWith("/")) { targetUrl.append(exchange.getRequest().getContextPath()); } targetUrl.append(getUrl()); if (StringUtils.hasText(targetUrl)) { Map<String, String> uriVars = getCurrentUriVariables(exchange); targetUrl = expandTargetUrlTemplate(targetUrl.toString(), model, uriVars); } if (isPropagateQuery()) { targetUrl = appendCurrentRequestQuery(targetUrl.toString(), exchange.getRequest()); } String result = targetUrl.toString(); RequestDataValueProcessor processor = getRequestDataValueProcessor(); return (processor != null ? processor.processUrl(exchange, result) : result); }