本文整理汇总了Java中org.springframework.http.HttpStatus.is4xxClientError方法的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.is4xxClientError方法的具体用法?Java HttpStatus.is4xxClientError怎么用?Java HttpStatus.is4xxClientError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.is4xxClientError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: errorPage
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
@RequestMapping(produces = "text/html")
public String errorPage(HttpServletRequest request, Model model) {
String message, error;
HttpStatus status = getStatus(request);
RequestAttributes requestAttributes = new ServletRequestAttributes(request);
Map<String, Object> attributeMap = this.errorAttributes.getErrorAttributes(requestAttributes, false);
if (attributeMap != null) {
message = (String) attributeMap.get("message");
error = (String) attributeMap.get("error");
model.addAttribute("header", error);
model.addAttribute("message", message);
}
if (status.is4xxClientError()){
if(status.value() == 404) {
model.addAttribute("header", "Sorry but we couldn't find this page");
model.addAttribute("message", "This page you are looking for does not exist.");
} else if (status.value() == 403) {
model.addAttribute("header", "Access denied");
model.addAttribute("message", "Full authentication is required to access this resource.");
}
} else if (status.value() == 500){
model.addAttribute("header", "Internal Server Error");
model.addAttribute("message",
"If the problem persists feel free to create an issue in Github.");
}
model.addAttribute("number", status.value());
return "errorPage";
}
示例2: canDecode
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
@Override
public boolean canDecode(HttpStatus httpStatus) {
return httpStatus.is4xxClientError();
}
示例3: getLoggingLevel
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
protected LoggingLevel getLoggingLevel(HttpStatus responseHttpStatus) {
return responseHttpStatus.is4xxClientError() ? errorestProperties.getHttpClientError().getLoggingLevel() : ERROR;
}
示例4: getErrorCode
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
protected String getErrorCode(HttpStatus responseHttpStatus) {
return responseHttpStatus.is4xxClientError() ? HTTP_CLIENT_ERROR_CODE : UNEXPECTED_ERROR_CODE;
}