为什么登陆密码错误也提示开小差
/**
* 拦截业务的运行时异常
*/
@ExceptionHandler(ServiceException.class)
public BaseWebResult handleServiceException(ServiceException e) {
Integer code = e.getCode();
String message = e.getMessage();
e.printStackTrace();
return BaseWebResult.error(code, message);
}
* 拦截校验异常
@ExceptionHandler(MethodArgumentNotValidException.class)
public BaseWebResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
try{
message =message.split("arguments \\[\\]; default message \\[")[1];
Pattern pattern = Pattern.compile("default message \\[(.*?)\\]");
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
String defaultMessage = matcher.group(1);
return BaseWebResult.error(FrameErrorCodeConstants.FRAM_SELF_ERROR.getCode(), defaultMessage);
}catch (Exception e2){
return BaseWebResult.error(FrameErrorCodeConstants.FRAME_PARAM_ERROR);
是因为框架统一拦截拦掉了,可以按照上面的操作 单独放开
好的。
/**
* 拦截业务的运行时异常
*/
@ExceptionHandler(ServiceException.class)
public BaseWebResult handleServiceException(ServiceException e) {
Integer code = e.getCode();
String message = e.getMessage();
e.printStackTrace();
return BaseWebResult.error(code, message);
}
/**
* 拦截校验异常
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public BaseWebResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
String message = e.getMessage();
e.printStackTrace();
try{
message =message.split("arguments \\[\\]; default message \\[")[1];
Pattern pattern = Pattern.compile("default message \\[(.*?)\\]");
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
String defaultMessage = matcher.group(1);
return BaseWebResult.error(FrameErrorCodeConstants.FRAM_SELF_ERROR.getCode(), defaultMessage);
}
}catch (Exception e2){
}
return BaseWebResult.error(FrameErrorCodeConstants.FRAME_PARAM_ERROR);
}