powiedziałbym
request.getRequestURL() + "/my/url"
czyni pracę. Nie ma takiego zbudowany w funkcjonalności, wiosna: url zwraca UrlTag.class który ma poniżej metodę generowania URL, można użyć go jako insőiration o kodzie:
private String createUrl() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
StringBuilder url = new StringBuilder();
if (this.type == UrlType.CONTEXT_RELATIVE) {
// add application context to url
if (this.context == null) {
url.append(request.getContextPath());
}
else {
url.append(this.context);
}
}
if (this.type != UrlType.RELATIVE && this.type != UrlType.ABSOLUTE && !this.value.startsWith("/")) {
url.append("/");
}
url.append(replaceUriTemplateParams(this.value, this.params, this.templateParams));
url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1)));
String urlStr = url.toString();
if (this.type != UrlType.ABSOLUTE) {
// Add the session identifier if needed
// (Do not embed the session identifier in a remote link!)
urlStr = response.encodeURL(urlStr);
}
// HTML and/or JavaScript escape, if demanded.
urlStr = isHtmlEscape() ? HtmlUtils.htmlEscape(urlStr) : urlStr;
urlStr = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(urlStr) : urlStr;
return urlStr;
}
To zły sposób na zrobienie tego. Potrzebuję usługi, która jest używana przez do generowania adresów URL ... Potrzebuję czystej drogi, proszę –
Nanocom
Źle w jaki sposób? Nie ma takiej usługi, wiosna: URL mniej więcej tak samo, patrz źródło dołączone. –
OK, jeśli to powiesz ... Ale to szalone, że nie pomyśleli o tym, moim zdaniem! – Nanocom