Here are the examples of the java api org.springframework.web.HttpRequestMethodNotSupportedException taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
89 Examples
19
View Source File : DefaultExceptionAdvice.java
License : Apache License 2.0
Project Creator : zlt2000
License : Apache License 2.0
Project Creator : zlt2000
/**
* 返回状态码:405
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler({ HttpRequestMethodNotSupportedException.clreplaced })
public Result handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return defHandler("不支持当前请求方法", e);
}
19
View Source File : ErrorController.java
License : GNU General Public License v3.0
Project Creator : zhshuixian
License : GNU General Public License v3.0
Project Creator : zhshuixian
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public MyResponse httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return new MyResponse("ERROR", e.getMessage());
}
19
View Source File : ExceptionTranslator.java
License : Apache License 2.0
Project Creator : viz-centric
License : Apache License 2.0
Project Creator : viz-centric
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage());
}
19
View Source File : DefaultExceptionAdvice.java
License : Apache License 2.0
Project Creator : dearMOMO
License : Apache License 2.0
Project Creator : dearMOMO
/**
* 返回状态码:405
*/
@ResponseStatus(HttpStatus.OK)
@ExceptionHandler({ HttpRequestMethodNotSupportedException.clreplaced })
public JSONResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return defHandler(null, "不支持当前请求方法", e);
}
18
View Source File : ErrorRestControllerAdvice.java
License : GNU General Public License v3.0
Project Creator : zhshuixian
License : GNU General Public License v3.0
Project Creator : zhshuixian
/**
* Http Method 异常 返回 405
*
* @param e Exception
* @return 错误信息
*/
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public MyResponse httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return new MyResponse("ERROR", e.getMessage());
}
18
View Source File : DefaultExceptionHandler.java
License : Apache License 2.0
Project Creator : yin5980280
License : Apache License 2.0
Project Creator : yin5980280
/**
* 请求方式不支持
*/
@ExceptionHandler({ HttpRequestMethodNotSupportedException.clreplaced })
public ResponseEnreplacedy<Response> handleException(HttpRequestMethodNotSupportedException e) {
log.error(e.getMessage(), e);
return ResponseEnreplacedy.ok(Response.buildError("不支持' " + e.getMethod() + "'请求"));
}
18
View Source File : GlobalExceptionConfig.java
License : MIT License
Project Creator : WeiziPlus
License : MIT License
Project Creator : WeiziPlus
/**
* 405异常
*
* @return
*/
@ExceptionHandler({ HttpRequestMethodNotSupportedException.clreplaced })
public ResultUtils httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException ex) {
return ResultUtils.error("请使用" + ex.getSupportedHttpMethods() + "方法请求,详情:" + ex.getMessage());
}
18
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : PearAdmin
License : MIT License
Project Creator : PearAdmin
/**
* 不 支 持 的 请 求 类 型
*/
@ExceptionHandler({ HttpRequestMethodNotSupportedException.clreplaced })
public Result handleException(HttpRequestMethodNotSupportedException e) {
log.error(e.getMessage(), e);
return Result.failure("不支持' " + e.getMethod() + "'请求");
}
18
View Source File : OneOffSpringWebMvcFrameworkExceptionHandlerListenerTest.java
License : Apache License 2.0
Project Creator : Nike-Inc
License : Apache License 2.0
Project Creator : Nike-Inc
@Test
public void shouldHandleException_returns_METHOD_NOT_ALLOWED_for_HttpRequestMethodNotSupportedException() {
// given
HttpRequestMethodNotSupportedException ex = new HttpRequestMethodNotSupportedException("asplode");
// when
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(ex);
// then
validateResponse(result, true, singletonList(testProjectApiErrors.getMethodNotAllowedApiError()));
}
18
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : leecho
License : MIT License
Project Creator : leecho
@ResponseBody
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public Result handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
log.error(ErrorStatus.METHOD_NOT_ALLOWED.getMessage() + ":" + e.getMessage());
return failure(ErrorStatus.METHOD_NOT_ALLOWED, e);
}
18
View Source File : BaseRestApiControllerAdviceTest.java
License : Apache License 2.0
Project Creator : eclipse
License : Apache License 2.0
Project Creator : eclipse
@Test
public void testBaseRestApiControllerAdviceHttpRequestMethodNotSupportedException() {
HttpRequestMethodNotSupportedExceptionHandler httpRequestMethodNotSupportedExceptionHandler = new HttpRequestMethodNotSupportedExceptionHandler();
HttpRequestMethodNotSupportedException e = new HttpRequestMethodNotSupportedException("GET");
RestApiErrorResponse actualErrorResponse = httpRequestMethodNotSupportedExceptionHandler.handleException(e);
replacedert.replacedertNotNull(actualErrorResponse);
replacedert.replacedertTrue(actualErrorResponse.getErrorDetails().getErrorMessage().equals("Method Not Allowed"));
}
18
View Source File : HttpRequestMethodNotSupportedExceptionHandler.java
License : Apache License 2.0
Project Creator : eclipse
License : Apache License 2.0
Project Creator : eclipse
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ResponseBody
public RestApiErrorResponse handleException(final HttpRequestMethodNotSupportedException e) {
return super.handleException(e, HttpStatus.METHOD_NOT_ALLOWED.getReasonPhrase());
}
18
View Source File : GlobalExceptionHandler.java
License : Apache License 2.0
Project Creator : DarLiner
License : Apache License 2.0
Project Creator : DarLiner
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public ResultInfo handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException ex) {
return new ResultInfo(ResultCode.NOT_FOUND);
}
18
View Source File : GlobalExceptionHandler.java
License : GNU General Public License v3.0
Project Creator : coti-io
License : GNU General Public License v3.0
Project Creator : coti-io
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResponseEnreplacedy<ExceptionResponse> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
log.info("Received a request with unsupported method");
log.info(EXCEPTION_MESSAGE + e.getMessage());
return new ResponseEnreplacedy<>(new ExceptionResponse(METHOD_NOT_SUPPORTED, API_CLIENT_ERROR), HttpStatus.NOT_FOUND);
}
18
View Source File : ExceptionHandle.java
License : Apache License 2.0
Project Creator : bz51
License : Apache License 2.0
Project Creator : bz51
/**
* 请求方法不正确
* @param exception
* @return
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public Result HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
throw new CommonBizException(ExpCodeEnum.HTTP_REQ_METHOD_ERROR);
}
18
View Source File : GlobalExceptionHandler.java
License : Apache License 2.0
Project Creator : beifei1
License : Apache License 2.0
Project Creator : beifei1
/**
* 405
* @param e
* @return
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public R methodNotAllowedExceptionHandler(HttpRequestMethodNotSupportedException e) {
return R.fail(BaseException.BaseErrorEnum.MESSAGE_NOT_ALLOWED.getCode(), e.getMessage());
}
18
View Source File : BaseAdvice.java
License : MIT License
Project Creator : aoju
License : MIT License
Project Creator : aoju
/**
* 请求方式拦截
*
* @param e 异常信息
* @return 异常提示
*/
@ResponseBody
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
public Object httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return write(ErrorCode.EM_100507);
}
18
View Source File : Xs2aRestExceptionHandler.java
License : Apache License 2.0
Project Creator : adorsys
License : Apache License 2.0
Project Creator : adorsys
@Override
protected ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
tppErrorMessageWriter.writeError(response, new TppErrorMessage(ERROR, SERVICE_INVALID_405_METHOD_NOT_SUPPORTED, ex.getMethod()));
return new ModelAndView();
}
17
View Source File : GlobleExceptionHandler.java
License : Apache License 2.0
Project Creator : yy1261633791
License : Apache License 2.0
Project Creator : yy1261633791
/**
* 请求的方式不支持
*
* @param ex
* @return
*/
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
public JsonResult errorHandler(HttpRequestMethodNotSupportedException ex) {
log.error(ex.getMessage(), ex);
return JsonResult.error().put("message", "Http 方式不正确," + ex.getMessage());
}
17
View Source File : ExceptionTranslator.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
log.debug("Method not supported", exception);
return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, localizationErrorMessageService.getMessage(ErrorConstants.ERR_METHOD_NOT_SUPPORTED));
}
17
View Source File : GlobalExceptionHandler.java
License : Apache License 2.0
Project Creator : xiuhuai
License : Apache License 2.0
Project Creator : xiuhuai
/**
* 405 - Method Not Allowed
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public Map<String, Object> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
logger.error("不支持当前请求方法", e);
Map<String, Object> map = new HashMap<String, Object>();
map.put("rspCode", 405);
map.put("rspMsg", e.getMessage());
// 发生异常进行日志记录,写入数据库或者其他处理,此处省略
return map;
}
17
View Source File : RestExceptionAspect.java
License : MIT License
Project Creator : toesbieya
License : MIT License
Project Creator : toesbieya
// 请求方法有误
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public R handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return R.fail("请求方法有误");
}
17
View Source File : RestExceptionAspect.java
License : MIT License
Project Creator : toesbieya
License : MIT License
Project Creator : toesbieya
// 请求方法有误
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public R handle(HttpRequestMethodNotSupportedException e) {
return R.fail("请求方法有误");
}
17
View Source File : GlobalDefaultExceptionHandler.java
License : Apache License 2.0
Project Creator : suricate-io
License : Apache License 2.0
Project Creator : suricate-io
/**
* Manage the HttpRequestMethodNotSupportedException exception.
* Throw when a user try to access a resource with a not supported Http Verb.
*
* @param exception The exception
* @return The response
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResponseEnreplacedy<ApiErrorDto> handleRequestException(HttpRequestMethodNotSupportedException exception) {
GlobalDefaultExceptionHandler.LOGGER.debug("An exception has occurred in the API controllers part", exception);
return ResponseEnreplacedy.status(ApiErrorEnum.BAD_REQUEST.getStatus()).body(new ApiErrorDto(exception.getMessage(), ApiErrorEnum.BAD_REQUEST));
}
17
View Source File : DefaultExceptionHandler.java
License : GNU Affero General Public License v3.0
Project Creator : seagull1985
License : GNU Affero General Public License v3.0
Project Creator : seagull1985
/**
* 请求方式不支持
*/
@ExceptionHandler({ HttpRequestMethodNotSupportedException.clreplaced })
public AjaxResult handleException(HttpRequestMethodNotSupportedException e) {
log.error(e.getMessage(), e);
return AjaxResult.error("不支持' " + e.getMethod() + "'请求");
}
17
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : rstyro
License : MIT License
Project Creator : rstyro
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public Result HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException ex) {
logger.error(ex.getMessage(), ex);
return Result.error(ApiResultEnum.ERROR_MOTHODNOTSUPPORT);
}
17
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : qinming99
License : MIT License
Project Creator : qinming99
/**
* 405 - Method Not Allowed
* 带有@ResponseStatus注解的异常类会被ResponseStatusExceptionResolver 解析
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResultVO<String> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
log.error("", e);
return ResultVO.fail(ResultCodeEnum.METHOD_NOT_ALLOWED);
}
17
View Source File : FeedbackyExceptionHandler.java
License : MIT License
Project Creator : Plajer
License : MIT License
Project Creator : Plajer
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResponseEnreplacedy handleNotSupported(HttpRequestMethodNotSupportedException ex) {
return ResponseEnreplacedy.status(HttpStatus.METHOD_NOT_ALLOWED).body(new RestApiError(HttpStatus.METHOD_NOT_ALLOWED, "Supported methods: " + Arrays.toString(ex.getSupportedMethods())));
}
17
View Source File : WebRestControllerAdvice.java
License : MIT License
Project Creator : ParveenBhadooOfficial
License : MIT License
Project Creator : ParveenBhadooOfficial
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResponseEnreplacedy<ApiError> handleMethodNotSupportedException(HttpRequestMethodNotSupportedException ex) {
ApiError apiError = new ApiError(HttpStatus.METHOD_NOT_ALLOWED, ex.getMessage(), null);
return new ResponseEnreplacedy<>(apiError, apiError.getStatus());
}
17
View Source File : ExceptionTranslator.java
License : GNU General Public License v3.0
Project Creator : klask-io
License : GNU General Public License v3.0
Project Creator : klask-io
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ErrorDTO processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
return new ErrorDTO(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage());
}
17
View Source File : BaseExceptionHandler.java
License : Apache License 2.0
Project Creator : JacksonTu
License : Apache License 2.0
Project Creator : JacksonTu
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public CommonResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
String message = "该方法不支持" + StringUtils.substringBetween(e.getMessage(), "'", "'") + "请求方法";
log.error(message);
return new CommonResult().message(message);
}
17
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : i-am-vt
License : MIT License
Project Creator : i-am-vt
/**
* 请求方式不支持
*/
@ExceptionHandler({ HttpRequestMethodNotSupportedException.clreplaced })
public Result<Void> handleException(HttpRequestMethodNotSupportedException e) {
log.error(e.getMessage(), e);
return Result.error("不支持' " + e.getMethod() + "'请求");
}
17
View Source File : GlobalExceptionHandler.java
License : BSD 3-Clause "New" or "Revised" License
Project Creator : hxnlyw
License : BSD 3-Clause "New" or "Revised" License
Project Creator : hxnlyw
/**
* 不支持方法异常处理
*
* @param ex
* @return
*/
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.OK)
public ErrorResponse handleException(HttpRequestMethodNotSupportedException ex) {
printRequestDetail();
printApiCodeException(ResponseEnum.METHOD_NOT_ALLOWED, ex);
return ErrorResponse.result(ResponseEnum.METHOD_NOT_ALLOWED);
}
17
View Source File : BaseExceptionHandler.java
License : Apache License 2.0
Project Creator : febsteam
License : Apache License 2.0
Project Creator : febsteam
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public FebsResponse handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
String message = "该方法不支持" + StringUtils.substringBetween(e.getMessage(), "'", "'") + "请求方法";
log.error(message);
return new FebsResponse().message(message);
}
17
View Source File : ExceptionAspect.java
License : MIT License
Project Creator : DanielLin07
License : MIT License
Project Creator : DanielLin07
/**
* 405 - Method Not Allowed
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public Response handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
log.error("request_method_not_supported...", e);
return new Response().failure("request_method_not_supported");
}
17
View Source File : ExceptionTranslator.java
License : Apache License 2.0
Project Creator : cai3178940
License : Apache License 2.0
Project Creator : cai3178940
/**
* http method有误
*
* @param exception
* @return
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseBody
public ResponseEnreplacedy<ReplyVO> processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
return buildErrorResponse(ErrorCode.METHOD_NOT_ALLOWED);
}
17
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : 7040210
License : MIT License
Project Creator : 7040210
/**
* 不支持当前请求方法
*
* @param e 异常信息
* @return
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public BaseMessage handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return pubTools.genNoMsg(StatusCode.METHOD_NOT_ALLOWED, e.getMessage());
}
16
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : YunaiV
License : MIT License
Project Creator : YunaiV
/**
* 处理 SpringMVC 请求方法不正确
*
* 例如说,A 接口的方法为 GET 方式,结果请求方法为 POST 方式,导致不匹配
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public CommonResult<?> httpRequestMethodNotSupportedExceptionHandler(HttpRequestMethodNotSupportedException ex) {
log.warn("[httpRequestMethodNotSupportedExceptionHandler]", ex);
return CommonResult.error(METHOD_NOT_ALLOWED.getCode(), String.format("请求方法不正确:%s", ex.getMessage()));
}
16
View Source File : GlobalExceptionHandler.java
License : Apache License 2.0
Project Creator : xiuhuai
License : Apache License 2.0
Project Creator : xiuhuai
/**
* 405 - Method Not Allowed
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public String handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e, Model model) {
logger.error("不支持当前请求方法", e);
String message = "【不支持当前请求方法】" + e.getMessage();
model.addAttribute("message", message);
model.addAttribute("code", 405);
return viewName;
}
16
View Source File : GlobalExceptionTranslator.java
License : MIT License
Project Creator : spring2go
License : MIT License
Project Creator : spring2go
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public BaseResponse handleError(HttpRequestMethodNotSupportedException e) {
logger.error("Request Method Not Supported", e);
return BaseResponse.builder().code(ResultCode.METHOD_NOT_SUPPORTED).message(e.getMessage()).build();
}
16
View Source File : GlobalExceptionHandler.java
License : GNU General Public License v3.0
Project Creator : saysky
License : GNU General Public License v3.0
Project Creator : saysky
/**
* 405 - Method Not Allowed
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public String handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e, Model model) {
log.error("不支持当前请求方法", e);
String message = "【不支持当前请求方法】" + e.getMessage();
model.addAttribute("message", message);
model.addAttribute("code", 405);
return viewName;
}
16
View Source File : GlobalDefaultExceptionHandler.java
License : Apache License 2.0
Project Creator : purgeteam
License : Apache License 2.0
Project Creator : purgeteam
/**
* HttpRequestMethodNotSupportedException 405 异常处理
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public Result handlerHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) throws Throwable {
errorDispose(e);
outPutErrorWarn(HttpRequestMethodNotSupportedException.clreplaced, CommonErrorCode.METHOD_NOT_ALLOWED, e);
return Result.ofFail(CommonErrorCode.METHOD_NOT_ALLOWED);
}
16
View Source File : AbstractExceptionTranslator.java
License : MIT License
Project Creator : luban-h5
License : MIT License
Project Creator : luban-h5
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
protected ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException ex) {
String errorCode = ErrorEnum.ERR_METHOD_NOT_SUPPORTED.getError();
ErrorVM error = new ErrorVM(errorCode, ex.getMessage(), HttpStatus.METHOD_NOT_ALLOWED.value());
log.error("HttpRequestMethodNotSupportedException[" + error.getErrorId() + "]: " + ex.getMessage(), ex);
return error;
}
16
View Source File : GlobalCustomRestExceptionHandler.java
License : Apache License 2.0
Project Creator : hulichao
License : Apache License 2.0
Project Creator : hulichao
// 这里请求方法不支持的异常
@Override
protected ResponseEnreplacedy<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
final Result error = Result.fail(status.value(), "HttpRequestMethodNotSupported");
return new ResponseEnreplacedy<Object>(error, new HttpHeaders(), status);
}
16
View Source File : GlobalHandler.java
License : Apache License 2.0
Project Creator : herowzz
License : Apache License 2.0
Project Creator : herowzz
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResponseEnreplacedy<ApiResult<?>> HttpRequestMethodNotSupportedException(HttpServletRequest request, HttpRequestMethodNotSupportedException ex) {
ApiResult<?> dto = new ApiResult<>();
dto.code = ApiResultCodeEnum.HTTP_METHOD_NOT_SUPPORT.code;
dto.msg = ApiResultCodeEnum.HTTP_METHOD_NOT_SUPPORT.msg + "(" + ex.getMessage() + ")";
return new ResponseEnreplacedy<ApiResult<?>>(dto, HttpStatus.OK);
}
16
View Source File : ExceptionHandling.java
License : GNU Affero General Public License v3.0
Project Creator : Hello-hao
License : GNU Affero General Public License v3.0
Project Creator : Hello-hao
@ExceptionHandler
public String test3(HttpRequestMethodNotSupportedException e, Model model) {
ModelAndView modelAndView = new ModelAndView("/index");
Print.Normal("URL访问类型不正确:" + e.getMessage());
// e.printStackTrace();
modelAndView.addObject("error", "URL访问类型不正确。");
model.addAttribute("error", "URL访问类型不正确。");
// 返回错误信息,并显示给用户
// return e.getMessage();
return "exception";
}
16
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : Ha2ryZhang
License : MIT License
Project Creator : Ha2ryZhang
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
public Result<String> parameterException(HttpRequestMethodNotSupportedException exception) {
String mg = "请求方式错误";
log.error("错误信息:" + mg);
return Result.error(CodeMsg.BIND_ERROR.fillArgs(mg));
}
16
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : fengwenyi
License : MIT License
Project Creator : fengwenyi
/*============= 请求错误 start ==============================================*/
/**
* HTTP 请求方式不支持异常
* HttpRequestMethodNotSupportedException
* @return 异常
*/
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
public ResultTemplate<Void> HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
return ResultTemplate.fail(IReturnCode.Default.ERROR_REQUEST_METHOD_NOT_SUPPORT);
}
16
View Source File : GlobalHandlerExceptionResolver.java
License : Apache License 2.0
Project Creator : fast-family
License : Apache License 2.0
Project Creator : fast-family
@ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public // 对于接口方法不匹配的异常处理
Response handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
logError("httpRequestMethodNotSupportedException", e.getMessage(), e);
return Response.fail(405, e.getMessage());
}
16
View Source File : HttpRequestMethodNotSupportedExceptionHandler.java
License : Apache License 2.0
Project Creator : fangjinuo
License : Apache License 2.0
Project Creator : fangjinuo
@Override
public RestRespBody<String> handle(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) {
if (!(exception instanceof HttpRequestMethodNotSupportedException)) {
}
HttpRequestMethodNotSupportedException ex = (HttpRequestMethodNotSupportedException) exception;
RestRespBody<String> respBody = RestRespBody.error(405, "HTTP-405", null);
if (Emptys.isNotEmpty(ex.getSupportedMethods())) {
String supportedMethods = Strings.join(", ", ex.getSupportedMethods());
response.setHeader("Allow", supportedMethods);
respBody.setErrorMessage("支持的HTTP Method有:" + supportedMethods);
}
return respBody;
}
See More Examples