보드 딜리트 페이지 가젼오디
@RequestMapping(value="boardDelete.aws")
public String boardDelet(@RequestParam("bidx") int bidx,Model model){
model.addAttribute("bidx",bidx);
String path="WEB-INF/board/boardDelete";
return path;
}
// 삭제하기 기능
@RequestMapping(value="boardDeleteAction.aws", method=RequestMethod.POST)
public String boardDeleteAction(
@RequestParam("bidx") int bidx,
@RequestParam("password") String password,
HttpSession session
){
int midx = Integer.parseInt(session.getAttribute("midx").toString());
boardService.boardDelete(bidx,midx,password);
String path = "redirect:/board/boardList.aws";
return path;
}
public int boardDelete(int bidx, int midx, String password);
2., 서비스 가기
public int boardDelete(HashMap hm);
4. 매개변수에 가ㅓㅄ을 여러개를 담아야 하기 때문에 이럴때는 스프링에서 해쉬맵으로 값을 보낸다. 보드매펄에는 해쉬맵으로 매개변수를 넣는다.
@Override
public int boardDelete(int bidx, int midx, String password) {
HashMap<String,Object> hm = new HashMap<String,Object>();
hm.put("bidx", bidx);
hm.put("midx", midx);
hm.put("password", password);
int cnt = bm.boardDelete(hm);
return cnt;
}
<!-- 게시물 삭제하는 쿼리 구문 -->
<update id="boardDelete" parameterType="HashMap">
update board set delyn='Y', modifyday=now() where bidx= #{bidx} and midx=#{midx} and password=#{password}
</update>

// 삭제하기 기능
@RequestMapping(value="boardDeleteAction.aws", method=RequestMethod.POST)
public String boardDeleteAction(
@RequestParam("bidx") int bidx,
@RequestParam("password") String password,
HttpSession session,
RedirectAttributes rttr
){
BoardVo bv = boardService.boardSelectOne(bidx);
int midx = Integer.parseInt(session.getAttribute("midx").toString());
int value = boardService.boardDelete(bidx,midx,password);
String path = "";
if(bv.getMidx()==midx) {
if(value==1) {
path = "redirect:/board/boardList.aws";
}else {
rttr.addFlashAttribute("msg", "비밀번호가 틀렸습니다.");
path = "redirect:/board/boardDelete.aws?bidx="+bidx;
}
}else {
rttr.addFlashAttribute("msg", "글을 쓴 회원이 아닙니다.");
path = "redirect:/board/boardDelete.aws?bidx="+bidx;
}
return path; // .jsp는 WEB-INF/spring/appServlet/servlet-context.xml > 에서 붇어짐
}