spark.Request.queryParamOrDefault()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(169)

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

Request.queryParamOrDefault介绍

[英]Gets the query param, or returns default value
[中]获取查询参数,或返回默认值

代码示例

代码示例来源:origin: gocd/gocd

public String search(Request request, Response response) throws IOException {
    String pipelineName = request.queryParams("pipeline_name");
    String fingerprint = request.queryParams("fingerprint");
    String searchText = request.queryParamOrDefault("search_text", "");
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MatchedRevision> matchedRevisions = materialService.searchRevisions(pipelineName, fingerprint, searchText, currentUsername(), result);
    if (result.isSuccessful()) {
      return writerForTopLevelArray(request, response, outputListWriter -> MatchedRevisionRepresenter.toJSON(outputListWriter, matchedRevisions));
    } else {
      return renderHTTPOperationResult(result, request, response);
    }
  }
}

代码示例来源:origin: komoot/photon

locationDistanceSort = Boolean.valueOf(webRequest.queryParamOrDefault("distance_sort", "true"));
} catch (Exception nfe) {
  throw new BadRequestException(400, "invalid parameter 'distance_sort', can only be true or false");

代码示例来源:origin: org.opentcs/opentcs-kernel-extension-http-services

private boolean disableVehicle(Request request) {
  return Boolean.parseBoolean(request.queryParamOrDefault("disableVehicle", "false"));
 }
}

代码示例来源:origin: org.opentcs/opentcs-kernel-extension-http-services

private boolean immediate(Request request) {
 return Boolean.parseBoolean(request.queryParamOrDefault("immediate", "false"));
}

代码示例来源:origin: org.opentcs/opentcs-kernel-extension-http-services

private long minSequenceNo(Request request)
  throws IllegalArgumentException {
 String param = request.queryParamOrDefault("minSequenceNo", "0");
 try {
  return Long.parseLong(param);
 }
 catch (NumberFormatException exc) {
  throw new IllegalArgumentException("Malformed minSequenceNo: " + param);
 }
}

代码示例来源:origin: org.opentcs/opentcs-kernel-extension-http-services

private long maxSequenceNo(Request request)
  throws IllegalArgumentException {
 String param = request.queryParamOrDefault("maxSequenceNo", String.valueOf(Long.MAX_VALUE));
 try {
  return Long.parseLong(param);
 }
 catch (NumberFormatException exc) {
  throw new IllegalArgumentException("Malformed minSequenceNo: " + param);
 }
}

代码示例来源:origin: org.opentcs/opentcs-kernel-extension-http-services

private long timeout(Request request)
  throws IllegalArgumentException {
 String param = request.queryParamOrDefault("timeout", "1000");
 try {
  // Allow a maximum timeout of 10 seconds so server threads are only bound for a limited time.
  return Math.min(10000, Long.parseLong(param));
 }
 catch (NumberFormatException exc) {
  throw new IllegalArgumentException("Malformed timeout: " + param);
 }
}

代码示例来源:origin: org.apache.james/james-server-webadmin-mailrepository

private MailDto getMailAsJson(MailRepositoryPath path, MailKey mailKey, Request request) {
  try {
    return repositoryStoreService.retrieveMail(path, mailKey, extractAdditionalFields(request.queryParamOrDefault("additionalFields", "")))
      .orElseThrow(mailNotFoundError(mailKey));
  } catch (MailRepositoryStore.MailRepositoryStoreException | MessagingException e) {
    throw internalServerError(e);
  } catch (IllegalArgumentException e) {
    throw invalidField(e);
  } catch (InaccessibleFieldException e) {
    throw inaccessibleField(e);
  }
}

相关文章