本文整理汇总了Java中org.springframework.http.HttpStatus.I_AM_A_TEAPOT属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.I_AM_A_TEAPOT属性的具体用法?Java HttpStatus.I_AM_A_TEAPOT怎么用?Java HttpStatus.I_AM_A_TEAPOT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.I_AM_A_TEAPOT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addNewEats
@GetMapping(path="/addNewEats") // Map ONLY GET Requests
@ResponseBody
public ResponseEntity<Object> addNewEats (@RequestParam String email
, @RequestParam String numServings
, @RequestParam String foodName) {
int s;
try {
s = Integer.parseInt(numServings);
} catch (NumberFormatException e ) {
return new ResponseEntity<>("Number of servings is invalid", HttpStatus.NOT_ACCEPTABLE);
}
if (userRepository.findByEmail(email) == null) {
return new ResponseEntity<>("Email does not exist", HttpStatus.NOT_ACCEPTABLE);
}
if (foodRepository.findByFoodName(foodName) == null) {
return new ResponseEntity<>(foodName + " does not exist", HttpStatus.NOT_ACCEPTABLE);
}
if (email.equals("[email protected]")) {
return new ResponseEntity<>("[email protected] TERMINATION SCHEDULED. NUTRITIONAL MAINTENANCE IRRELLEVANT", HttpStatus.I_AM_A_TEAPOT);
}
Eats eats = new Eats(userRepository.findByEmail(email), s, foodRepository.findByFoodName(foodName));
eatsRepository.save(eats);
return new ResponseEntity<>("Eat transaction added", HttpStatus.OK);
}
示例2: coffee
@ApiOperation(value = "HTCPCP Implementation", notes = "HTCPCP", hidden = true)
@RequestMapping(path = "/coffee", method = RequestMethod.GET)
public ResponseEntity<String> coffee() {
StatusJSON json = new StatusJSON("I'm a teapot \u2615");
return new ResponseEntity<>(json.toString(), HttpStatus.I_AM_A_TEAPOT);
}