本文整理汇总了Java中org.springframework.web.bind.annotation.PathVariable类的典型用法代码示例。如果您正苦于以下问题:Java PathVariable类的具体用法?Java PathVariable怎么用?Java PathVariable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathVariable类属于org.springframework.web.bind.annotation包,在下文中一共展示了PathVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParticipantFromCGOR
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@ApiOperation(value = "getParticipantFromCGOR", nickname = "getParticipantFromCGOR")
@RequestMapping(value = "/CISConnector/getParticipantFromCGOR/{cgorName}", method = RequestMethod.GET)
@ApiImplicitParams({
@ApiImplicitParam(name = "cgorName", value = "the CGOR name", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "query")
})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = Participant.class),
@ApiResponse(code = 400, message = "Bad Request", response = Participant.class),
@ApiResponse(code = 500, message = "Failure", response = Participant.class)})
public ResponseEntity<Participant> getParticipantFromCGOR(@PathVariable String cgorName, @QueryParam("organisation") String organisation) {
log.info("--> getParticipantFromCGOR: " + cgorName);
Participant participant;
try {
participant = connector.getParticipantFromCGOR(cgorName, organisation);
} catch (CISCommunicationException e) {
log.error("Error executing the request: Communication Error" , e);
participant = null;
}
HttpHeaders responseHeaders = new HttpHeaders();
log.info("getParticipantFromCGOR -->");
return new ResponseEntity<Participant>(participant, responseHeaders, HttpStatus.OK);
}
示例2: helloWithOptionalName
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@RequestMapping({ "helloWithOptionalName", "helloWithOptional/{name}" })
public ObjectNode helloWithOptionalName(@PathVariable Optional<String> name) {
ObjectNode resultJson = jacksonMapper.createObjectNode();
logger.info( "simple log" ) ;
if (name.isPresent() )
resultJson.put("name", name.get()) ;
else
resultJson.put( "name", "not-provided" ) ;
resultJson.put( "Response", "Hello from " + HOST_NAME + " at "
+ LocalDateTime.now().format( DateTimeFormatter.ofPattern( "HH:mm:ss, MMMM d uuuu " ) ));
return resultJson ;
}
示例3: getMovieById
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
/**
* Get movie info by movie id.
*
* @param id movie id
* @param model spring model
* @return movie detail page
*/
@RequestMapping(value = "/movies/{id}", method = RequestMethod.GET)
public String getMovieById(@PathVariable Long id, Model model) {
Movie movie = movieRepository.getMovie(Long.toString(id));
if (movie != null) {
if (movie.getImageUri() != null) {
movie.setImageFullPathUri(
azureStorageUploader.getAzureStorageBaseUri(applicationContext) + movie.getImageUri());
}
model.addAttribute("movie", movie);
return "moviedetail";
} else {
return "moviedetailerror";
}
}
示例4: bookQuery
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@RequestMapping(value="/checkin/{flightNumber}/{origin}/{destination}/{flightDate}/{fare}/{firstName}/{lastName}/{gender}/{bookingid}", method=RequestMethod.GET)
public String bookQuery(@PathVariable String flightNumber,
@PathVariable String origin,
@PathVariable String destination,
@PathVariable String flightDate,
@PathVariable String fare,
@PathVariable String firstName,
@PathVariable String lastName,
@PathVariable String gender,
@PathVariable String bookingid,
Model model) {
CheckInRecord checkIn = new CheckInRecord(firstName, lastName, "28C", null,
flightDate,flightDate, new Long(bookingid).longValue());
long checkinId = checkInClient.postForObject("http://checkin-apigateway/api/checkin/create", checkIn, long.class);
model.addAttribute("message","Checked In, Seat Number is 28c , checkin id is "+ checkinId);
return "checkinconfirm";
}
示例5: atualizar
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
/**
* Atualiza os dados de um lançamento.
*
* @param id
* @param lancamentoDto
* @return ResponseEntity<Response<Lancamento>>
* @throws ParseException
*/
@PutMapping(value = "/{id}")
public ResponseEntity<Response<LancamentoDto>> atualizar(@PathVariable("id") Long id,
@Valid @RequestBody LancamentoDto lancamentoDto, BindingResult result) throws ParseException {
log.info("Atualizando lançamento: {}", lancamentoDto.toString());
Response<LancamentoDto> response = new Response<LancamentoDto>();
validarFuncionario(lancamentoDto, result);
lancamentoDto.setId(Optional.of(id));
Lancamento lancamento = this.converterDtoParaLancamento(lancamentoDto, result);
if (result.hasErrors()) {
log.error("Erro validando lançamento: {}", result.getAllErrors());
result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage()));
return ResponseEntity.badRequest().body(response);
}
lancamento = this.lancamentoService.persistir(lancamento);
response.setData(this.converterLancamentoDto(lancamento));
return ResponseEntity.ok(response);
}
示例6: deleteIdentityLink
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@RequestMapping(value="/task/{taskId}/identity/{type}/{identityId}", method = RequestMethod.DELETE, name="任务候选人删除")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteIdentityLink(@PathVariable("taskId") String taskId, @PathVariable("identityId") String identityId,
@PathVariable("type") String type) {
Task task = getTaskFromRequest(taskId,false);
validateIdentityLinkArguments(identityId, type);
getIdentityLink(taskId, identityId, type);
if (TaskIdentityRequest.AUTHORIZE_GROUP.equals(type)) {
taskService.deleteGroupIdentityLink(task.getId(), identityId,IdentityLinkType.CANDIDATE);
} else if(TaskIdentityRequest.AUTHORIZE_USER.equals(type)) {
taskService.deleteUserIdentityLink(task.getId(), identityId,IdentityLinkType.CANDIDATE);
}
}
示例7: updateUser
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@PutMapping(value = "/{id}")
public ResponseEntity<User> updateUser(@PathVariable("id") long id, @RequestBody User user) {
logger.info("Updating User: {} ", user);
Optional<User> optionalUser = userService.findById(id);
if (optionalUser.isPresent()) {
User currentUser = optionalUser.get();
currentUser.setUsername(user.getUsername());
currentUser.setAddress(user.getAddress());
currentUser.setEmail(user.getEmail());
userService.updateUser(currentUser);
return ResponseEntity.ok(currentUser);
}
else {
logger.warn("User with id :{} doesn't exists", id);
return ResponseEntity.notFound().build();
}
}
示例8: deleteClientConfiguration
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@DeleteMapping(path = "/{id:.*}")
public void deleteClientConfiguration(HttpServletRequest request, HttpServletResponse response,
@PathVariable ClientID id) throws IOException {
HTTPRequest httpRequest = ServletUtils.createHTTPRequest(request);
try {
ClientDeleteRequest clientDeleteRequest = ClientDeleteRequest.parse(httpRequest);
resolveAndValidateClient(id, clientDeleteRequest);
this.clientRepository.deleteById(id);
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
catch (GeneralException e) {
ClientRegistrationResponse registrationResponse = new ClientRegistrationErrorResponse(e.getErrorObject());
ServletUtils.applyHTTPResponse(registrationResponse.toHTTPResponse(), response);
}
}
示例9: appTagTopic
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/tagapp/topic/{catalog}/{tagId}.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String appTagTopic(@PathVariable short catalog, @PathVariable int tagId) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
try {
Set<AppTopic> list = service.getAppTopic(tagId, catalog);
output.put("result", server);
output.put("data", list);
output.put("total", list == null ? 0 : list.size());
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} catch (Exception e) {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
logger.error("Exception", e);
}
return output.toJSONString(jsonStyle);
}
示例10: findBranchGrayRules
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules",
method = RequestMethod.GET)
public GrayReleaseRuleDTO findBranchGrayRules(@PathVariable String appId,
@PathVariable String clusterName,
@PathVariable String namespaceName,
@PathVariable String branchName) {
checkBranch(appId, clusterName, namespaceName, branchName);
GrayReleaseRule rules = namespaceBranchService.findBranchGrayRules(appId, clusterName, namespaceName, branchName);
if (rules == null) {
return null;
}
GrayReleaseRuleDTO ruleDTO =
new GrayReleaseRuleDTO(rules.getAppId(), rules.getClusterName(), rules.getNamespaceName(),
rules.getBranchName());
ruleDTO.setReleaseId(rules.getReleaseId());
ruleDTO.setRuleItems(GrayReleaseRuleItemTransformer.batchTransformFromJSON(rules.getRules()));
return ruleDTO;
}
示例11: getBuildsByBoardName
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@RequestMapping(value = "/dashboards/{name}/builds", method = GET,
produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getBuildsByBoardName(@PathVariable("name") String name) {
DashboardDTO dashboard = dashboardService.getDashboard(name);
if (dashboard == null || dashboard.getCodeRepos() == null
|| dashboard.getCodeRepos().isEmpty()) {
return null;
}
List<Build> builds = buildService
.getLastBuildsByKeywordsAndByTeamMembers(
dashboard.getCodeRepos(), dashboard.getTeamMembers());
BuildStats stats = buildService.getStatsByKeywordsAndByTeamMembers(
dashboard.getCodeRepos(), dashboard.getTeamMembers());
Map<String, Object> response = new HashMap<>();
response.put("lastBuilds", builds);
response.put("stats", stats);
return response;
}
示例12: editPostWithId
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
/**
* Edit post with provided id.
* It is not possible to edit if the user is not authenticated
* and if he is now the owner of the post
*
* @param id
* @param principal
* @return post model and postForm view, for editing post
*/
@RequestMapping(value = "/editPost/{id}", method = RequestMethod.GET)
public ModelAndView editPostWithId(@PathVariable Long id, Principal principal) {
ModelAndView modelAndView = new ModelAndView();
Post post = postService.findPostForId(id);
// Not possible to edit if user is not logged in, or if he is now the owner of the post
if (principal == null || !principal.getName().equals(post.getUser().getUsername())) {
modelAndView.setViewName("403");
}
if (post == null) {
modelAndView.setViewName("404");
} else {
modelAndView.addObject("post", post);
modelAndView.setViewName("postForm");
}
return modelAndView;
}
示例13: oneRawImage
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@GetMapping(value = BASE_PATH + "/" + FILENAME + "/raw",
produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public Mono<ResponseEntity<?>> oneRawImage(
@PathVariable String filename) {
// tag::try-catch[]
return imageService.findOneImage(filename)
.map(resource -> {
try {
return ResponseEntity.ok()
.contentLength(resource.contentLength())
.body(new InputStreamResource(
resource.getInputStream()));
} catch (IOException e) {
return ResponseEntity.badRequest()
.body("Couldn't find " + filename +
" => " + e.getMessage());
}
});
// end::try-catch[]
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:22,代码来源:UploadController.java
示例14: getTopicDetails
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
/**
* GET Details for a specific Topic.
*/
@ResponseBody
@RequestMapping(path = "/cluster/{id}/topic/{topic}/details", method = RequestMethod.GET, produces = "application/json")
public TopicDetails getTopicDetails(@PathVariable final Long id, @PathVariable final String topic) {
// Retrieve cluster
final Cluster cluster = clusterRepository.findOne(id);
if (cluster == null) {
throw new NotFoundApiException("TopicDetails", "Unable to find cluster");
}
// Create new Operational Client
try (final KafkaOperations operations = createOperationsClient(cluster)) {
return operations.getTopicDetails(topic);
} catch (final Exception e) {
throw new ApiException("TopicDetails", e);
}
}
示例15: deleteBranch
import org.springframework.web.bind.annotation.PathVariable; //导入依赖的package包/类
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}", method = RequestMethod.DELETE)
public void deleteBranch(@PathVariable String appId,
@PathVariable String env,
@PathVariable String clusterName,
@PathVariable String namespaceName,
@PathVariable String branchName) {
boolean canDelete = permissionValidator.hasReleaseNamespacePermission(appId, namespaceName) ||
(permissionValidator.hasModifyNamespacePermission(appId, namespaceName) &&
releaseService.loadLatestRelease(appId, Env.valueOf(env), branchName, namespaceName) == null);
if (!canDelete) {
throw new AccessDeniedException("Forbidden operation. "
+ "Caused by: 1.you don't have release permission "
+ "or 2. you don't have modification permission "
+ "or 3. you have modification permission but branch has been released");
}
namespaceBranchService.deleteBranch(appId, Env.valueOf(env), clusterName, namespaceName, branchName);
}