fix: repair shadow candidate planning and site runtime errors
This commit is contained in:
@@ -3,6 +3,7 @@ package com.ruoyi.framework.web.exception;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.InvalidPropertyException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
@@ -90,6 +91,23 @@ public class GlobalExceptionHandler
|
||||
return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), value));
|
||||
}
|
||||
|
||||
@ExceptionHandler(InvalidPropertyException.class)
|
||||
public AjaxResult handleInvalidPropertyException(InvalidPropertyException e, HttpServletRequest request)
|
||||
{
|
||||
String property = e.getPropertyName();
|
||||
boolean bindingFailure = java.util.Arrays.stream(e.getStackTrace()).anyMatch(frame ->
|
||||
frame.getClassName().equals("org.springframework.web.method.annotation.ModelAttributeMethodProcessor")
|
||||
&& frame.getMethodName().equals("resolveArgument"));
|
||||
if (!bindingFailure || property == null || !property.contains("[")
|
||||
|| !request.getParameterMap().containsKey(property))
|
||||
{
|
||||
return handleRuntimeException(e, request);
|
||||
}
|
||||
log.warn("请求地址'{}',请求参数结构不正确", request.getRequestURI());
|
||||
return AjaxResult.error(HttpStatus.BAD_REQUEST,
|
||||
"请求参数格式不正确,单号等普通字段请传单个值,不要传对象或数组");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user