本文整理了Java中spark.Request.queryParamOrDefault
方法的一些代码示例,展示了Request.queryParamOrDefault
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.queryParamOrDefault
方法的具体详情如下:
包路径:spark.Request
类名称: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!