* Access controller , Throw exception @GetMapping( value = "/exception/{id}") public void
testException(@PathVariable Integer id) { System.out.println("exception");
throw new UserNotExistException(id); }
* Custom exception class public class UserNotExistException extends RuntimeException{ private
static final long serialVersionUID = 1L; private Integer id; public
UserNotExistException(Integer id) { super("User Not Exist sss"); this.id = id;
} public Integer getId() { return id; } public void setId(Integer id) { this.id
= id; } }
* Define exception controller handling @ControllerAdvice public class ControllerExceptionHandle {
@ExceptionHandler(UserNotExistException.class) @ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public Map<String,Object>
handleUserNotExistExctption(UserNotExistException ex){ Map<String,Object> map =
new HashMap<String,Object>(); System.out.println(map); map.put("id",
ex.getId()); map.put("message", "ControllerExceptionHandle :
UserNotExistException"); return map; } }

©2019-2020 Toolsou All rights reserved,
Python+OpenCV Detailed explanation of face recognition technology SpringBoot practice ( five ):mybatis-plus In BaseMapper,Iservice and ServiceImpl Google says home office affects work efficiency !2021 Return to offline office in 2010 C Language programming to find a student's grade vue Of v-if And v-show The difference between C Language console games , Make bricks These songs , Programmers, don't listen ! What should I do if I suddenly encounter a question I can't answer during the interview ?python To solve the problem of dictionary writing list in c Linguistic 5 Three common sorting methods