Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
web:framework:spring:exceptions [2024/11/29 09:43] – jcheron | web:framework:spring:exceptions [2025/08/12 02:35] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 10: | Ligne 10: | ||
===== ExceptionHandler ===== | ===== ExceptionHandler ===== | ||
+ | L' | ||
+ | |||
+ | <sxh java> | ||
+ | @ControllerAdvice | ||
+ | public class MainAdvice { | ||
+ | |||
+ | @ExceptionHandler({TodoNotFoundException.class, | ||
+ | public String handleTodoNotFoundException(RedirectAttributes attributes) { | ||
+ | InfoMessage msg = InfoMessage.error(" | ||
+ | attributes.addFlashAttribute(" | ||
+ | return " | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Validation ===== | ||
+ | |||
+ | <sxh xml> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||