public String encodeURL(String url) { return resp.encodeURL(url); }
@Override public String encodeUrl(String url) { return response.encodeURL(url); }
@Override public String encodeURL(String url) { return response.encodeURL(url); }
/** * @param arg0 * @return * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String) */ @Override public String encodeURL(String arg0) { return response.encodeURL(arg0); }
/** * Return a context-aware URl for the given relative URL. * @param relativeUrl the relative URL part * @return a URL that points back to the server with an absolute path (also URL-encoded accordingly) */ public String getContextUrl(String relativeUrl) { String url = getContextPath() + relativeUrl; if (this.response != null) { url = this.response.encodeURL(url); } return url; }
private String resolvePublicResourceUrlPath(String path) { return this.servlet.wrappedResponse.encodeURL(path); }
/** * The default behavior of this method is to call encodeURL(String url) * on the wrapped response object. */ public String encodeURL(String url) { return this._getHttpServletResponse().encodeURL(url); }
/** * Return a context-aware URl for the given relative URL. * @param relativeUrl the relative URL part * @return a URL that points back to the server with an absolute path (also URL-encoded accordingly) */ public String getContextUrl(String relativeUrl) { String url = getContextPath() + relativeUrl; if (this.response != null) { url = this.response.encodeURL(url); } return url; }
@Signature public String encodeUrl(String url) { return response.encodeURL(url); }
urlStr = response.encodeURL(urlStr);
/** * Return a context-aware URl for the given relative URL with placeholders (named keys with braces {@code {}}). * For example, send in a relative URL {@code foo/{bar}?spam={spam}} and a parameter map * {@code {bar=baz,spam=nuts}} and the result will be {@code [contextpath]/foo/baz?spam=nuts}. * @param relativeUrl the relative URL part * @param params a map of parameters to insert as placeholders in the url * @return a URL that points back to the server with an absolute path (also URL-encoded accordingly) */ public String getContextUrl(String relativeUrl, Map<String, ?> params) { String url = getContextPath() + relativeUrl; UriTemplate template = new UriTemplate(url); url = template.expand(params).toASCIIString(); if (this.response != null) { url = this.response.encodeURL(url); } return url; }
/** * <p> * Process an already-built URL just before returning it. * </p> * <p> * By default, this method will apply the {@code HttpServletResponse.encodeURL(url)} mechanism, as standard * when using the Java Servlet API. Note however that this will only be applied if {@code context} is * an implementation of {@code IWebContext} (i.e. the Servlet API will only be applied in web environments). * </p> * <p> * This method can be overridden by any subclasses that want to change this behaviour (e.g. in order to * avoid using the Servlet API). * </p> * * @param context the execution context. * @param link the already-built URL. * @return the processed URL, ready to be used. */ protected String processLink(final IExpressionContext context, final String link) { if (!(context instanceof IWebContext)) { return link; } final HttpServletResponse response = ((IWebContext)context).getResponse(); return (response != null? response.encodeURL(link) : link); }
urlStr = response.encodeURL(urlStr);
/** * Return a context-aware URl for the given relative URL with placeholders (named keys with braces {@code {}}). * For example, send in a relative URL {@code foo/{bar}?spam={spam}} and a parameter map * {@code {bar=baz,spam=nuts}} and the result will be {@code [contextpath]/foo/baz?spam=nuts}. * @param relativeUrl the relative URL part * @param params a map of parameters to insert as placeholders in the url * @return a URL that points back to the server with an absolute path (also URL-encoded accordingly) */ public String getContextUrl(String relativeUrl, Map<String, ?> params) { String url = getContextPath() + relativeUrl; UriTemplate template = new UriTemplate(url); url = template.expand(params).toASCIIString(); if (this.response != null) { url = this.response.encodeURL(url); } return url; }
private void testEncodeUrl(MockHttpServletRequest request, String url, String expected) throws ServletException, IOException { this.filter.doFilter(request, new MockHttpServletResponse(), (req, res) -> { req.setAttribute(ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR, this.urlProvider); String result = ((HttpServletResponse) res).encodeURL(url); assertEquals(expected, result); }); }
requestUri = ((HttpServletResponse) response).encodeURL(requestUri); String queryString = getRequestContext().getQueryString(); if (StringUtils.hasText(queryString)) {
@Test public void encodeUrlWithContextAndForwardedRequest() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/context/foo"); request.setContextPath("/context"); this.filter.doFilter(request, new MockHttpServletResponse(), (req, res) -> { req.setAttribute(ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR, this.urlProvider); request.setRequestURI("/forwarded"); request.setContextPath("/"); String result = ((HttpServletResponse) res).encodeURL("/context/resources/bar.css"); assertEquals("/context/resources/bar-11e16cf79faee7ac698c805cf28248d2.css", result); }); }
requestUri = ((HttpServletResponse) response).encodeURL(requestUri); String queryString = getRequestContext().getQueryString(); if (StringUtils.hasText(queryString)) {
@Override public String encodeUrl(String s) { return servletResponse.encodeURL(s); }
@Override public String encodeURL(String s) { return servletResponse.encodeURL(s); }