org.kohsuke.stapler.StaplerRequest.getLocalPort()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(60)

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

StaplerRequest.getLocalPort介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Infers the hudson installation URL from the given request.
 */
public static String inferHudsonURL(StaplerRequest req) {
  String rootUrl = Jenkins.getInstance().getRootUrl();
  if(rootUrl !=null)
    // prefer the one explicitly configured, to work with load-balancer, frontend, etc.
    return rootUrl;
  StringBuilder buf = new StringBuilder();
  buf.append(req.getScheme()).append("://");
  buf.append(req.getServerName());
  if(! (req.getScheme().equals("http") && req.getLocalPort()==80 || req.getScheme().equals("https") && req.getLocalPort()==443))
    buf.append(':').append(req.getLocalPort());
  buf.append(req.getContextPath()).append('/');
  return buf.toString();
}

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

/**
 * Infers the hudson installation URL from the given request.
 */
public static String inferHudsonURL(StaplerRequest req) {
  String rootUrl = Hudson.getInstance().getRootUrl();
  if(rootUrl !=null)
    // prefer the one explicitly configured, to work with load-balancer, frontend, etc.
    return rootUrl;
  StringBuilder buf = new StringBuilder();
  buf.append(req.getScheme()).append("://");
  buf.append(req.getServerName());
  if(req.getLocalPort()!=80)
    buf.append(':').append(req.getLocalPort());
  buf.append(req.getContextPath()).append('/');
  return buf.toString();
}

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

/**
 * Infers the hudson installation URL from the given request.
 */
public static String inferHudsonURL(StaplerRequest req) {
  String rootUrl = Hudson.getInstance().getRootUrl();
  if(rootUrl !=null)
    // prefer the one explicitly configured, to work with load-balancer, frontend, etc.
    return rootUrl;
  StringBuilder buf = new StringBuilder();
  buf.append(req.getScheme()).append("://");
  buf.append(req.getServerName());
  if(req.getLocalPort()!=80)
    buf.append(':').append(req.getLocalPort());
  buf.append(req.getContextPath()).append('/');
  return buf.toString();
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Infers the hudson installation URL from the given request.
 */
public static String inferHudsonURL(StaplerRequest req) {
  String rootUrl = Jenkins.getInstance().getRootUrl();
  if(rootUrl !=null)
    // prefer the one explicitly configured, to work with load-balancer, frontend, etc.
    return rootUrl;
  StringBuilder buf = new StringBuilder();
  buf.append(req.getScheme()).append("://");
  buf.append(req.getServerName());
  if(! (req.getScheme().equals("http") && req.getLocalPort()==80 || req.getScheme().equals("https") && req.getLocalPort()==443))
    buf.append(':').append(req.getLocalPort());
  buf.append(req.getContextPath()).append('/');
  return buf.toString();
}

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

/**
 * Infers the hudson installation URL from the given request.
 */
public static String inferHudsonURL(StaplerRequest req) {
  String rootUrl = Hudson.getInstance().getRootUrl();
  if (rootUrl != null) // prefer the one explicitly configured, to work with load-balancer, frontend, etc.
  {
    return rootUrl;
  }
  StringBuilder buf = new StringBuilder();
  buf.append(req.getScheme()).append("://");
  buf.append(req.getServerName());
  if (req.getLocalPort() != 80) {
    buf.append(':').append(req.getLocalPort());
  }
  buf.append(getRequestRootPath(req)).append('/');
  return buf.toString();
}

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

/**
 * Infers the hudson installation URL from the given request.
 */
public static String inferHudsonURL(StaplerRequest req) {
  String rootUrl = Hudson.getInstance().getRootUrl();
  if(rootUrl !=null)
    // prefer the one explicitly configured, to work with load-balancer, frontend, etc.
    return rootUrl;
  StringBuilder buf = new StringBuilder();
  buf.append(req.getScheme()).append("://");
  buf.append(req.getServerName());
  if(req.getLocalPort()!=80)
    buf.append(':').append(req.getLocalPort());
  buf.append(req.getContextPath()).append('/');
  return buf.toString();
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法