本文整理匯總了Java中org.springframework.http.HttpStatus.BAD_GATEWAY屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpStatus.BAD_GATEWAY屬性的具體用法?Java HttpStatus.BAD_GATEWAY怎麽用?Java HttpStatus.BAD_GATEWAY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.BAD_GATEWAY屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleServerErrors
private static void handleServerErrors(HttpStatus statusCode) throws IOException {
if (statusCode == HttpStatus.INTERNAL_SERVER_ERROR) {
throw new InternalServerErrorException(TWITTER,
"Something is broken at Twitter. Please see http://dev.twitter.com/pages/support to report the issue.");
} else if (statusCode == HttpStatus.BAD_GATEWAY) {
throw new ServerDownException(TWITTER, "Twitter is down or is being upgraded.");
} else if (statusCode == HttpStatus.SERVICE_UNAVAILABLE) {
throw new ServerOverloadedException(TWITTER, "Twitter is overloaded with requests. Try again later.");
}
}
示例2: Regist
@RequestMapping(value = "common",produces = "application/json;charset=UTF-8")
public ResponseEntity<HttpJson> Regist(@RequestBody String inObj){
HttpJson re = new HttpJson(), input = new HttpJson(inObj);
String thisFormType = input.getClassName();
if (!thisFormType.equals("form:regist")){
re.setStatusCode(250);
re.setMessage("不匹配的請求");
return new ResponseEntity<HttpJson>(re, HttpStatus.BAD_REQUEST);
}
String getRegistType = input.getPara("style");
String getUserName = input.getPara("username");
String getUserPwd = input.getPara("password");
Login login = new Login();
login.setUPwd(getUserPwd);
login.setUAName(getUserName);
String flag = "-2";
try {
flag = registService.registUserWithType(login,getRegistType);
} catch (Exception e) {
e.printStackTrace();
re.setMessage("服務器出錯");
re.setStatusCode(202);
re.constractJsonString();
return new ResponseEntity<HttpJson>(re,HttpStatus.BAD_GATEWAY);
}
if (flag.equals("-1")){
re.setMessage("用戶已存在,請檢查用戶名");
re.setStatusCode(201);
}else if(flag.equals("-2")){
re.setStatusCode(202);
re.setMessage("服務器太忙,請稍後再試");
}else{
re.setMessage("UserUUid");
re.setClassObject(String.class.toString());
re.setClassObject(flag);
}
re.constractJsonString();
return new ResponseEntity<HttpJson>(re,HttpStatus.ACCEPTED);
}
示例3: handleNotificationException
@ResponseStatus(value = HttpStatus.BAD_GATEWAY, reason = "Satellite Graphiums could not be notified")
@ExceptionHandler(NotificationException.class)
public void handleNotificationException(NotificationException ex) {
log.error("Error occured during request",ex);
}
示例4: defaultRestaurant
/**
* Fallback method for getRestaurant()
*
* @param restaurantId
* @return
*/
public ResponseEntity<Restaurant> defaultRestaurant(
@PathVariable int restaurantId) {
return new ResponseEntity<>(null, HttpStatus.BAD_GATEWAY);
}
開發者ID:PacktPublishing,項目名稱:Mastering-Microservices-with-Java-9-Second-Edition,代碼行數:10,代碼來源:RestaurantServiceAPI.java