当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatus.I_AM_A_TEAPOT属性代码示例

本文整理汇总了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);
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:28,代码来源:EatsController.java

示例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);
}
 
开发者ID:sinnerschrader,项目名称:SkillWill,代码行数:6,代码来源:HTCPCPImpl.java


注:本文中的org.springframework.http.HttpStatus.I_AM_A_TEAPOT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。