update 增加SpEL表达式解析异常处理
This commit is contained in:
parent
ec703ceeb8
commit
e672a3bc6c
@ -15,6 +15,7 @@ import org.dromara.common.core.exception.base.BaseException;
|
|||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||||
|
import org.springframework.expression.spel.SpelEvaluationException;
|
||||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
@ -210,4 +211,14 @@ public class GlobalExceptionHandler {
|
|||||||
return R.fail(HttpStatus.HTTP_BAD_REQUEST, "请求参数格式错误:" + e.getMostSpecificCause().getMessage());
|
return R.fail(HttpStatus.HTTP_BAD_REQUEST, "请求参数格式错误:" + e.getMostSpecificCause().getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SpEL 表达式解析异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(SpelEvaluationException.class)
|
||||||
|
public R<Void> handleSpelEvaluationException(SpelEvaluationException e, HttpServletRequest request) {
|
||||||
|
String requestURI = request.getRequestURI();
|
||||||
|
log.error("请求地址'{}',SpEL解析异常: {}", requestURI, e.getMessage());
|
||||||
|
return R.fail(HttpStatus.HTTP_INTERNAL_ERROR, "[SpEL解析失败] " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user