MCPcopy Create free account
hub / github.com/castello/spring_basic / ExceptionController

Class ExceptionController

ch2/ExceptionController.java:12–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10import org.springframework.web.bind.annotation.ResponseStatus;
11
12@Controller
13public class ExceptionController {
14 @ExceptionHandler({NullPointerException.class, FileNotFoundException.class})
15 public String catcher2(Exception ex, Model m) {
16 m.addAttribute("ex", ex);
17 return "error";
18 }
19
20 @ExceptionHandler(Exception.class)
21 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // 200 -> 500
22 public String catcher(Exception ex, Model m) {
23 System.out.println("catcher() in ExceptionController");
24 System.out.println("m="+m);
25// m.addAttribute("ex", ex);
26
27 return "error";
28 }
29
30 @RequestMapping("/ex")
31 public String main(Model m) throws Exception {
32 m.addAttribute("msg", "message from ExceptionController.main()");
33 throw new Exception("¿¹¿Ü°¡ ¹ß»ýÇß½À´Ï´Ù.");
34 }
35
36 @RequestMapping("/ex2")
37 public String main2() throws Exception {
38 throw new NullPointerException("¿¹¿Ü°¡ ¹ß»ýÇß½À´Ï´Ù.");
39 }
40}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected