提交 1cf270d2 authored 作者: 马晨俊's avatar 马晨俊

mcj:

修复出现异常时的返回值不为指定格式问题
上级 e0d50e1c
......@@ -6,6 +6,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
......@@ -14,14 +15,14 @@ import java.io.IOException;
* @author Mcj
* @date 2020-03-16 10:33
*/
@ControllerAdvice
@RestControllerAdvice
@Slf4j
public class ExceptionHandlerConfig {
@ExceptionHandler(value = HttpMessageNotReadableException.class)
public ServerResponse defaultErrorHandler(Exception e) {
log.error("http请求错误{}",e);
return ServerResponse.error();
return ServerResponse.badRequest();
}
@ExceptionHandler(value = IOException.class)
public ServerResponse defaultIOHandler(Exception e) {
......
......@@ -431,7 +431,6 @@ public class InspectController {
// System.out.println("上传文件失败");
// response.setStatus(415);
return ServerResponse.error(415, "上传文件失败");
}
}
......@@ -448,8 +447,6 @@ public class InspectController {
@PostMapping("/importExcelToRapidAssessment")
private ServerResponse<Reform> uploadFileToInspect(MultipartFile file, String username) throws IOException {
Reform reform = ExcelUtil.parseExcel(file.getInputStream(),file.getOriginalFilename());
reform.setUsername(username);
return ServerResponse.ok(reform);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论