本文整理匯總了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);
}
}
示例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);
}
示例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);
}
示例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);
}