hudson.model.Hudson.getRootUrlFromRequest()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中hudson.model.Hudson.getRootUrlFromRequest()方法的一些代码示例,展示了Hudson.getRootUrlFromRequest()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hudson.getRootUrlFromRequest()方法的具体详情如下:
包路径:hudson.model.Hudson
类名称:Hudson
方法名:getRootUrlFromRequest

Hudson.getRootUrlFromRequest介绍

[英]Gets the absolute URL of Hudson top page, such as "http://localhost/hudson/".

Unlike #getRootUrl(), which uses the manually configured value, this one uses the current request to reconstruct the URL. The benefit is that this is immune to the configuration mistake (users often fail to set the root URL correctly, especially when a migration is involved), but the downside is that unless you are processing a request, this method doesn't work.
[中]获取Hudson首页的绝对URL,例如“http://localhost/hudson/".
与使用手动配置的值的#getRootUrl()不同,此函数使用当前请求来重建URL。这样做的好处是不受配置错误的影响(用户通常无法正确设置根URL,尤其是在涉及迁移时),但缺点是,除非您正在处理请求,否则此方法不起作用。

代码示例

代码示例来源:origin: org.jvnet.hudson.plugins/findbugs

private String getImage(final String image) {
  Hudson hudson = Hudson.getInstance();
  String rootUrl;
  if (hudson == null) {
    rootUrl = StringUtils.EMPTY;
  }
  else {
    rootUrl = hudson.getRootUrlFromRequest();
  }
  return rootUrl + "/plugin/findbugs/icons/" + image;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

return getRootUrlFromRequest();

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Gets the absolute URL of Hudson,
 * such as "http://localhost/hudson/".
 *
 * <p>
 * This method first tries to use the manually configured value, then
 * fall back to {@link StaplerRequest#getRootPath()}.
 * It is done in this order so that it can work correctly even in the face
 * of a reverse proxy.
 *
 * @return
 *      This method returns null if this parameter is not configured by the user.
 *      The caller must gracefully deal with this situation.
 *      The returned URL will always have the trailing '/'.
 * @since 1.66
 * @see Descriptor#getCheckUrl(String)
 * @see #getRootUrlFromRequest()
 */
public String getRootUrl() {
  // for compatibility. the actual data is stored in Mailer
  String url = Mailer.descriptor().getUrl();
  if (url != null) {
    return url;
  }
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    return getRootUrlFromRequest();
  }
  return null;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Gets the absolute URL of Hudson,
 * such as "http://localhost/hudson/".
 *
 * <p>
 * This method first tries to use the manually configured value, then
 * fall back to {@link StaplerRequest#getRootPath()}.
 * It is done in this order so that it can work correctly even in the face
 * of a reverse proxy.
 *
 * @return
 *      This method returns null if this parameter is not configured by the user.
 *      The caller must gracefully deal with this situation.
 *      The returned URL will always have the trailing '/'.
 * @since 1.66
 * @see Descriptor#getCheckUrl(String)
 * @see #getRootUrlFromRequest()
 */
public String getRootUrl() {
  // for compatibility. the actual data is stored in Mailer
  String url = Mailer.descriptor().getUrl();
  if (url != null) {
    return url;
  }
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    return getRootUrlFromRequest();
  }
  return null;
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Gets the absolute URL of Hudson,
 * such as "http://localhost/hudson/".
 *
 * <p>
 * This method first tries to use the manually configured value, then
 * fall back to {@link StaplerRequest#getRootPath()}.
 * It is done in this order so that it can work correctly even in the face
 * of a reverse proxy.
 *
 * @return
 *      This method returns null if this parameter is not configured by the user.
 *      The caller must gracefully deal with this situation.
 *      The returned URL will always have the trailing '/'.
 * @since 1.66
 * @see Descriptor#getCheckUrl(String)
 * @see #getRootUrlFromRequest()
 */
public String getRootUrl() {
  // for compatibility. the actual data is stored in Mailer
  String url = Mailer.descriptor().getUrl();
  if (url != null) {
    return url;
  }
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    return getRootUrlFromRequest();
  }
  return null;
}

相关文章

微信公众号

最新文章

更多

Hudson类方法