postmapping 에 들어오는 parameter를 getmapping 과 동일한 @RequestParam 으로 생각했는데 아니었다.😂
@GetMapping("/read")
public String read(Integer bno, Integer page, Integer pageSize, Model m){
try{
BoardDto boardDto = boardService.read(bno);
m.addAttribute(boardDto);
m.addAttribute("page", page);
m.addAttribute("pageSize", pageSize);
}catch (Exception e){
e.printStackTrace();
}
return "board";
}
위 read 컨트롤러 처리 시 parameter 에 있는 bno 는 RequestParam 에서 가져오는 것임.
@PostMapping("/remove")
public String remove(Integer bno, Integer page, Integer pageSize, Model m, HttpSession session){
String writer = (String)session.getAttribute("id");
try {
m.addAttribute("page", page);
m.addAttribute("pageSize",pageSize);
int rowCnt = boardService.remove(bno,writer);
if(rowCnt != 1)
throw new Exception("board remove error");
m.addAttribute("msg", "DEL_OK");
} catch (Exception e) {
e.printStackTrace();
m.addAttribute("msg", "DEL_ERR");
}
return "redirect:/board/list";
}
위 postmapping 에서의 bno 파라미터 값은 jsp 에 있는 input 태그의 실제 값이었던 것…… value 는 있으나, name 을 적어주지 않아 계속 null 로 들어왔던 부분이다. jsp에 있는 name 꼭 지정해주는거 잊지 말기… value 가 있어도 name 이 없으면 해당 변수 못찾음.