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

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

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

StaplerRequest.hasParameter介绍

[英]Short for getParameter(name)!=null
[中]getParameter(名称)的缩写=无效的

代码示例

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

/**
 * Depending on whether the user said "dismiss" or "correct", send him to the right place.
 */
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.hasParameter("correct")) {
    rsp.sendRedirect(req.getContextPath()+"/pluginManager");
  }
}

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

@RequirePOST
public HttpResponse doScan(StaplerRequest req) throws IOException, GeneralSecurityException {
  if(req.hasParameter("background")) {
    start(false);
  } else
  if(req.hasParameter("schedule")) {
    scanOnBoot.on();
  } else
  if(req.hasParameter("dismiss")) {
    disable(true);
  } else
    throw HttpResponses.error(400,"Invalid request submission: " + req.getParameterMap());
  return HttpResponses.redirectViaContextPath("/manage");
}

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

long lastModified = fileParameter.lastModified();
long contentLength = fileParameter.length();
if (request.hasParameter("view")) {
  response.serveFile(request, data, lastModified, contentLength, "plain.txt");
} else {

代码示例来源:origin: jenkinsci/gitlab-plugin

private WebHookAction onGet(Job<?, ?> project, String restOfPath, StaplerRequest request) {
  Matcher commitMatcher = COMMIT_STATUS_PATTERN.matcher(restOfPath);
  if (restOfPath.isEmpty() && request.hasParameter("ref")) {
    return new BranchBuildPageRedirectAction(project, request.getParameter("ref"));
  } else if (restOfPath.endsWith("status.png")) {
    return onGetStatusPng(project, request);
  } else if (commitMatcher.matches()) {
    return onGetCommitStatus(project, commitMatcher.group("sha1"), commitMatcher.group("statusJson"));
  }
  LOGGER.log(Level.FINE, "Unknown GET request: {0}", restOfPath);
  return new NoopAction();
}

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

/**
 * Depending on whether the user said "yes" or "no", send him to the right place.
 */
@RequirePOST
public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (req.hasParameter("no")) {
    disable(true);
    return HttpResponses.redirectViaContextPath("/manage");
  } else {
    return new HttpRedirect("manage");
  }
}

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

/**
 * Gets the list of suggestions that match the given query.
 *
 * @return
 *      can be empty but never null. The size of the list is always smaller than
 *      a certain threshold to avoid showing too many options. 
 */
public SearchResult getSuggestions(StaplerRequest req, String query) {
  Set<String> paths = new HashSet<String>();  // paths already added, to control duplicates
  SearchResultImpl r = new SearchResultImpl();
  int max = req.hasParameter("max") ? Integer.parseInt(req.getParameter("max")) : 100;
  SearchableModelObject smo = findClosestSearchableModelObject(req);
  for (SuggestedItem i : suggest(makeSuggestIndex(req), query, smo)) {
    if(r.size()>=max) {
      r.hasMoreResults = true;
      break;
    }
    if(paths.add(i.getPath()))
      r.add(i);
  }
  return r;
}

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

/**
 * Depending on whether the user said "yes" or "no", send him to the right place.
 */
@RequirePOST
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.hasParameter("no")) {
    disable(true);
    rsp.sendRedirect(req.getContextPath()+"/manage");
  } else {
    rsp.sendRedirect(req.getContextPath()+"/newView");
  }
}

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

/**
 * Called from the management screen.
 */
@RequirePOST
public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException {
  Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
  if(req.hasParameter("n")) {
    // we'll shut up
    disable(true);
    return HttpResponses.redirectViaContextPath("/manage");
  }
  return new HttpRedirect("confirm");
}

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

/**
   * Depending on whether the user said "yes" or "no", send him to the right place.
   */
  @RequirePOST
  public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
    if(req.hasParameter("no")) {
      disable(true);
      rsp.sendRedirect(req.getContextPath()+"/manage");
    } else {
      rsp.sendRedirect(req.getContextPath()+"/configureSecurity");
    }
  }
}

代码示例来源:origin: jenkinsci/gitlab-plugin

private WebHookAction onGetStatusPng(Job<?, ?> project, StaplerRequest request) {
  if (request.hasParameter("ref")) {
    return new BranchStatusPngAction(project, request.getParameter("ref"));
  } else {
    return new CommitStatusPngAction(project, request.getParameter("sha1"));
  }
}

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

@RequirePOST
public HttpResponse doUpdateSources(StaplerRequest req) throws IOException {
  Jenkins.getInstance().checkPermission(CONFIGURE_UPDATECENTER);
  if (req.hasParameter("remove")) {
    UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
    BulkChange bc = new BulkChange(uc);
    try {
      for (String id : req.getParameterValues("sources"))
        uc.getSites().remove(uc.getById(id));
    } finally {
      bc.commit();
    }
  } else
  if (req.hasParameter("add"))
    return new HttpRedirect("addSite");
  return new HttpRedirect("./sites");
}

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

@Override
  public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
    Jenkins j = Jenkins.get();
    try {
      // for compatibility reasons, this value is stored in Jenkins
      String num = json.getString("numExecutors");
      if (!num.matches("\\d+")) {
        throw new FormException(Messages.Hudson_Computer_IncorrectNumberOfExecutors(),"numExecutors");
      }
      
      j.setNumExecutors(json.getInt("numExecutors"));
      if (req.hasParameter("master.mode"))
        j.setMode(Mode.valueOf(req.getParameter("master.mode")));
      else
        j.setMode(Mode.NORMAL);

      j.setLabelString(json.optString("labelString", ""));

      return true;
    } catch (IOException e) {
      throw new FormException(e,"numExecutors");
    }
  }
}

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

blockBuildWhenUpstreamBuilding = json.optBoolean("blockBuildWhenUpstreamBuilding");
if(req.hasParameter("customWorkspace.directory")) {
} else if(req.hasParameter("_.assignedLabelString")) {

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

/**
 * Depending on whether the user said "dismiss" or "correct", send him to the right place.
 */
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.hasParameter("correct")) {
    rsp.sendRedirect(req.getContextPath()+"/pluginManager");
  }
}

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

@Override
protected void submit(StaplerRequest req, StaplerResponse rsp)
  throws IOException, ServletException, Descriptor.FormException {
  super.submit(req, rsp);
  setCustomWorkspace(
    req.hasParameter("customWorkspace") ? req.getParameter("customWorkspace.directory") : null);
}

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

/**
 * Depending on whether the user said "yes" or "no", send him to the right place.
 */
public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (req.hasParameter("no")) {
    disable(true);
    return HttpResponses.redirectViaContextPath("/manage");
  } else {
    return new HttpRedirect("manage");
  }
}

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

/**
 * Depending on whether the user said "yes" or "no", send him to the right place.
 */
@RequirePOST
public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (req.hasParameter("no")) {
    disable(true);
    return HttpResponses.redirectViaContextPath("/manage");
  } else {
    return new HttpRedirect("manage");
  }
}

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

/**
 * Depending on whether the user said "yes" or "no", send him to the right place.
 */
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.hasParameter("no")) {
    disable(true);
    rsp.sendRedirect(req.getContextPath()+"/manage");
  } else {
    rsp.sendRedirect(req.getContextPath()+"/newView");
  }
}

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

/**
 * Depending on whether the user said "yes" or "no", send him to the right place.
 */
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.hasParameter("no")) {
    disable(true);
    rsp.sendRedirect(req.getContextPath()+"/manage");
  } else {
    rsp.sendRedirect(req.getContextPath()+"/newView");
  }
}

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

/**
 * Depending on whether the user said "yes" or "no", send him to the right place.
 */
@RequirePOST
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.hasParameter("no")) {
    disable(true);
    rsp.sendRedirect(req.getContextPath()+"/manage");
  } else {
    rsp.sendRedirect(req.getContextPath()+"/newView");
  }
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法