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

Method list

ch4/BoardController3.java:98–122  ·  view source on GitHub ↗
(Model m, SearchCondition sc, HttpServletRequest request)

Source from the content-addressed store, hash-verified

96 }
97
98 @GetMapping("/list")
99 public String list(Model m, SearchCondition sc, HttpServletRequest request) {
100 if(!loginCheck(request))
101 return "redirect:/login/login?toURL="+request.getRequestURL(); // 로그인을 안했으면 로그인 화면으로 이동
102
103 try {
104 int totalCnt = boardService.getSearchResultCnt(sc);
105 m.addAttribute("totalCnt", totalCnt);
106
107 PageHandler pageHandler = new PageHandler(totalCnt, sc);
108
109 List<BoardDto> list = boardService.getSearchResultPage(sc);
110 m.addAttribute("list", list);
111 m.addAttribute("ph", pageHandler);
112
113 Instant startOfToday = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant();
114 m.addAttribute("startOfToday", startOfToday.toEpochMilli());
115 } catch (Exception e) {
116 e.printStackTrace();
117 m.addAttribute("msg", "LIST_ERR");
118 m.addAttribute("totalCnt", 0);
119 }
120
121 return "boardList"; // 로그인을 한 상태이면, 게시판 화면으로 이동
122 }
123
124 private boolean loginCheck(HttpServletRequest request) {
125 // 1. 세션을 얻어서(false는 session이 없어도 새로 생성하지 않는다. 반환값 null)

Callers

nothing calls this directly

Calls 3

loginCheckMethod · 0.95
getSearchResultCntMethod · 0.65
getSearchResultPageMethod · 0.65

Tested by

no test coverage detected