请求方式 不支持 异常抛出处理

获取userId
This commit is contained in:
2024-12-05 09:39:35 +08:00
parent c57fa40e29
commit 9ce1edafd3
3 changed files with 12 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import org.apache.shiro.authz.AuthorizationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.ServletWebRequest;
@@ -53,6 +54,13 @@ public class SqxExceptionHandler {
return Result.error("没有权限,请联系管理员授权");
}
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result httpRequestMethodNotSupportedException(Exception e, WebRequest webRequest) {
logErrorInfo(webRequest);
logger.error(e.getMessage());
return Result.error();
}
@ExceptionHandler(Exception.class)
public Result handleException(Exception e, WebRequest webRequest) {
logErrorInfo(webRequest);