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


Java HttpStatus.FOUND屬性代碼示例

本文整理匯總了Java中org.springframework.http.HttpStatus.FOUND屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpStatus.FOUND屬性的具體用法?Java HttpStatus.FOUND怎麽用?Java HttpStatus.FOUND使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.springframework.http.HttpStatus的用法示例。


在下文中一共展示了HttpStatus.FOUND屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: computeStatus

private HttpStatus computeStatus(Mode mode) {
    switch(mode) {
        case ALWAYS_OK:
            return HttpStatus.OK;
        case ALWAYS_WARNING:
            return HttpStatus.FOUND;
        case ALWAYS_CRITICAL:
            return HttpStatus.SERVICE_UNAVAILABLE;
        case DANGLING:
            Random random = new Random();
            int randomPos = random.nextInt() % Mode.values().length;
            if (randomPos < 0) {
                randomPos = randomPos * -1;
            }
            return computeStatus(Mode.values()[randomPos]);
        default:
            throw new IllegalArgumentException("Unable to manage mode " + mode);
    }

}
 
開發者ID:gilles-stragier,項目名稱:quickmon,代碼行數:20,代碼來源:DummyController.java

示例2: validateAdress

@RequestMapping(value = "validate", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<AddressDTO> validateAdress(@RequestBody AddressDTO addressDTO, HttpServletRequest request) {

    Address address;
    try {
        address = addressService.validateAddress(addressDTO);
    } catch (Exception e) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    if (address == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    AddressDTO adressDTO = mapToAdressDTO(address);

    return new ResponseEntity<>(adressDTO, HttpStatus.FOUND);

}
 
開發者ID:MrBW,項目名稱:resilient-transport-service,代碼行數:20,代碼來源:AddressController.java

示例3: searchById

@RequestMapping(value = "search/id")
@ResponseBody
public ResponseEntity<CustomerDTO> searchById(@RequestParam("customerId") Long customerId, HttpServletRequest request) {

    Customer customer;
    try {
        customer = customerService.findCustomerById(customerId);
    } catch (CustomerNotFoundException e) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    CustomerDTO customerDTO = mapToCustomerDTO(customer);

    return new ResponseEntity<>(customerDTO, HttpStatus.FOUND);

}
 
開發者ID:MrBW,項目名稱:resilient-transport-service,代碼行數:16,代碼來源:CustomerController.java

示例4: searchByName

@RequestMapping(value = "search/name")
@ResponseBody
public ResponseEntity<CustomerDTO> searchByName(@RequestParam("name") String name, HttpServletRequest request) {

    Customer customer;
    try {
        customer = customerService.findByName(name);

    } catch (CustomerNotFoundException e) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    CustomerDTO customerDTO = mapToCustomerDTO(customer);

    return new ResponseEntity<>(customerDTO, HttpStatus.FOUND);

}
 
開發者ID:MrBW,項目名稱:resilient-transport-service,代碼行數:17,代碼來源:CustomerController.java


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