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

Method main

ch2/YoilTellerMVC4.java:12–40  ·  view source on GitHub ↗
(MyDate date)

Source from the content-addressed store, hash-verified

10@Controller
11public class YoilTellerMVC4 {
12 @RequestMapping("/getYoilMVC4") // http://localhost/ch2/getYoilMVC4?year=2021&month=10&day=1
13 public ModelAndView main(MyDate date) { // 반환 타입이 ModelAndView
14System.out.println("date="+date);
15
16 // 1. ModelAndView를 생성
17 ModelAndView mv = new ModelAndView();
18
19 // 2. 유효성 검사
20 if(!isValid(date)) {
21 mv.setViewName("yoilError"); // 뷰의 이름을 지정
22 return mv;
23 }
24
25 // 3. 처리
26 char yoil = getYoil(date);
27
28 // 4. ModelAndView에 작업한 결과를 저장
29 //mv.addObject("year", date.getYear());
30 //mv.addObject("month", date.getMonth());
31 //mv.addObject("day", date.getDay());
32 mv.addObject("myDate", date);
33 mv.addObject("yoil", yoil);
34
35 // 5. 작업 결과를 보여줄 뷰의 이름을 지정
36 mv.setViewName("yoil");
37
38 // 6. ModelAndView를 반환
39 return mv;
40 }
41
42 private char getYoil(MyDate date) {
43 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