當前位置: 首頁>>代碼示例>>Java>>正文


Java PathVariable類代碼示例

本文整理匯總了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);
}
 
開發者ID:DRIVER-EU,項目名稱:CommonInformationSpace,代碼行數:28,代碼來源:CISAdaptorConnectorRestController.java

示例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 ;
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:18,代碼來源:HelloService.java

示例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";
    }
}
 
開發者ID:Microsoft,項目名稱:movie-db-java-on-azure,代碼行數:23,代碼來源:MovieController.java

示例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"; 
}
 
開發者ID:rajeshrv,項目名稱:SpringMicroservice,代碼行數:21,代碼來源:BrownFieldSiteController.java

示例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);
}
 
開發者ID:m4rciosouza,項目名稱:ponto-inteligente-api,代碼行數:28,代碼來源:LancamentoController.java

示例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);
    }
}
 
開發者ID:wengwh,項目名稱:plumdo-work,代碼行數:17,代碼來源:TaskIdentityResource.java

示例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();
	}

	
}
 
開發者ID:gauravrmazra,項目名稱:gauravbytes,代碼行數:22,代碼來源:UserController.java

示例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);
	}
}
 
開發者ID:vpavic,項目名稱:simple-openid-provider,代碼行數:19,代碼來源:ClientRegistrationEndpoint.java

示例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);
}
 
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:22,代碼來源:TagAppController.java

示例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;
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:24,代碼來源:NamespaceBranchController.java

示例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;
}
 
開發者ID:BBVA,項目名稱:mirrorgate,代碼行數:23,代碼來源:BuildController.java

示例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;
}
 
開發者ID:reljicd,項目名稱:spring-boot-blog,代碼行數:26,代碼來源:PostController.java

示例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);
    }
}
 
開發者ID:SourceLabOrg,項目名稱:kafka-webview,代碼行數:20,代碼來源:ApiController.java

示例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);

}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:23,代碼來源:NamespaceBranchController.java


注:本文中的org.springframework.web.bind.annotation.PathVariable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。