WANG 5 роки тому
батько
коміт
2d951a2145

+ 18 - 0
src/main/java/cn/com/qmth/examcloud/web/support/CustomExceptionHandler.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.support.MissingServletRequestPartException;
 
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
@@ -157,6 +158,23 @@ public class CustomExceptionHandler {
 		return asResult(e, body, request);
 	}
 
+	/**
+	 * 异常处理
+	 *
+	 * @author WANGWEI
+	 * @param e
+	 * @param request
+	 * @return
+	 */
+	@ExceptionHandler(MissingServletRequestPartException.class)
+	public ResponseEntity<StatusResponse> handleException(MissingServletRequestPartException e,
+			HttpServletRequest request) {
+
+		StatusResponse body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500",
+				e.getMessage());
+		return asResult(e, body, request);
+	}
+
 	/**
 	 * 异常处理
 	 *