BoardController2.java
페이지 정보
![profile_image](https://dancepkt.cafe24.com/data/member_image/ad/admin.gif?1630310007)
본문
package com.pkt.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.pkt.model.BoardVO;
import com.pkt.model.Criteria;
import com.pkt.model.PageMaker;
import com.pkt.service.BoardService;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j;
@Controller
@Log4j
@RequestMapping("/board/")
@AllArgsConstructor
public class BoardController2 {
private BoardService service;
@GetMapping("listPage")
public void listPage(@ModelAttribute("cri") Criteria cri, Model model) {
log.info(cri.toString());
model.addAttribute("list", service.listCriteria(cri)); //현재 페이지 리스트 출력 내용
PageMaker pageMaker = new PageMaker();
pageMaker.setCri(cri);
//pageMaker.setTotalCount(131); //임의로 131개로 데이터 입력 테스트
pageMaker.setTotalCount(service.listCountCriteria(cri)); //총 게시물 수
model.addAttribute("pageMaker", pageMaker); //현재 페이지에 해당하는 페이징 값들
}
@GetMapping("/registerPage")
public void registerGET() {
log.info("register get ...........");
}
@PostMapping("/registerPage")
public String registPagePOST(BoardVO board, RedirectAttributes rttr) {
log.info("registerPage post ...........");
log.info(board.toString());
service.regist(board);
rttr.addFlashAttribute("msg","register");
return "redirect:/board/listPage";
}
@GetMapping("/readPage")
public void readPage(@RequestParam("bno") int bno, Model model) {
log.info("readPage get ...........");
model.addAttribute(service.readOne(bno));
}
@GetMapping("/removePage")
public String removePage(@RequestParam("bno") int bno, RedirectAttributes rttr) {
log.info("removePage get ...........");
service.remove(bno);
rttr.addFlashAttribute("msg", "delete");
return "redirect:/board/listPage";
}
@GetMapping("/modifyPage")
public void modifyGET(int bno, Model model) {
log.info("modifyPage get ...........");
model.addAttribute(service.readOne(bno));
}
@PostMapping("/modifyPage")
public String modifyPOST(BoardVO board, RedirectAttributes rttr, int page) {
log.info("modifyPage post............");
service.modify(board);
rttr.addAttribute("page", page);
rttr.addFlashAttribute("msg", "modify");
return "redirect:/board/listPage";
}
}
- 이전글BoardServiceImpl.java 24.07.30
- 다음글board/listPage.jsp 24.07.30
댓글목록
등록된 댓글이 없습니다.