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

Method main

ch2/YoilTellerMVC5.java:19–38  ·  view source on GitHub ↗
(@ModelAttribute MyDate date, Model m)

Source from the content-addressed store, hash-verified

17 }
18
19 @RequestMapping("/getYoilMVC5") // http://localhost/ch2/getYoilMVC5?year=2021&month=10&day=1
20// public String main(@ModelAttribute("myDate") MyDate date, Model m) { // 아래와 동일
21 public String main(@ModelAttribute MyDate date, Model m) { // @ModelAttribute사용, 반환 타입은 String
22System.out.println("myDate="+date);
23
24 // 1. 유효성 검사
25 if(!isValid(date))
26 return "yoilError";
27
28 // 2. 처리
29 char yoil = getYoil(date);
30
31 // 3. Model에 작업한 결과를 저장
32 // @ModelAttribute 덕분에 MyDate를 저장안해도 됨. View로 자동 전달됨.
33// m.addAttribute("myDate", date);
34// m.addAttribute("yoil", yoil);
35
36 // 4. 작업 결과를 보여줄 뷰의 이름을 반환
37 return "yoil";
38 }
39
40 private @ModelAttribute("yoil") char getYoil(MyDate date) {
41 return getYoil(date.getYear(), date.getMonth(), date.getDay());

Callers

nothing calls this directly

Calls 2

isValidMethod · 0.95
getYoilMethod · 0.95

Tested by

no test coverage detected