Controller

@Override
	@RequestMapping(value="/removeNotice.do", method=RequestMethod.GET)
	public ModelAndView removerNotice(@RequestParam("bno")int bno,
				HttpServletRequest request, HttpServletResponse response)throws Exception{
		request.setCharacterEncoding("utf-8");
		noticeService.removeNotice(bno);
		ModelAndView mav = new ModelAndView("redirect:/admin/notice/noticeList.do");
		return mav;
	}
  • @Requestparam을 선언하여 bno의 값을 통해 삭제되게 controller 구현

Service

	@Override
	public int removeNotice(int bno)throws Exception{
		return noticeDAO.deleteNoticeList(bno);
	}

DAO

	@Override
	public int deleteNoticeList(int bno)throws DataAccessException{
		int result = sqlSession.delete("mapper.admin.notice.deleteNoticeList",bno);
			return result;
	}

 

js

 <script type="text/javascript">
 function fn_remove_bno(url,bno){
	 var form = document.createElement("form");
	 form.setAttribute("method", "get");
	 form.setAttribute("action", url);
     var bnoInput = document.createElement("input");
     bnoInput.setAttribute("type","hidden");
     bnoInput.setAttribute("name","bno");
     bnoInput.setAttribute("value", bno);
	 
     form.appendChild(bnoInput);
     document.body.appendChild(form);
     form.submit();
 
 }
 </script>
 
 ------------------------------------
 
 <input type=button value="삭제하기"  style='cursor:pointer;' 
	      	onClick="fn_remove_bno('${contextPath}/admin/notice/removeNotice.do', ${notice.bno})">
  • jsp에서 form태그를 통해 bno의 값을통해 삭제하게 하였다.
복사했습니다!