기록해! 정리해!

thymeleaf - getBoard 상세보기+delete 본문

SpringBoot

thymeleaf - getBoard 상세보기+delete

zsuling 2022. 10. 14. 12:25

1. getBoard.html 생성

 

<html xmlns:th="http://www.thymeleaaf.org">
<head>
<script>
 function listOk(){
	 
	 alert("목록보기");
	 location.href="getBoardList.do"
	 
 } 
 
 function delOk(sno){
	 
	 alert("삭제하기" + sno);	 
	 location.href="delete.do?sno="+sno;
 } 

</script>

<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<h2> 성적 상세보기 </h2>
<form action="updateOk.do">
<table border=1 >
<tr> <td > 번호 </td><td > <input type=text name="sno" id="sno"  th:value="${m.sno}" >  </td> </tr>
<tr> <td> 이름 </td> <td > <input type=text name=sname  id="sname" th:value="${m.sname}" ></td> </tr>
<tr> <td> 국어 </td><td > <input type=text  name=kor  id="kor" th:value="${m.kor}" >  </td> </tr>
<tr> <td> 영어 </td> <td > <input type=text name=eng  id="eng" th:value="${m.eng}" >  </td> </tr>
<tr> <td> 수학 </td><td > <input type=text  name=math  id="math" th:value="${m.math}" > </td> </tr>
<tr> <td> 역사 </td><td > <input type=text  name=hist  id="hist" th:value="${m.hist}" > </td> </tr>

<tr> <td colspan=2  align="center">
     <input type=button value="목록보기" onClick="listOk()" >
     <input type=submit value="수정하기" >
     <input type=button value="삭제하기"  th:onClick="delOk([[${m.sno}]])" >
     </td> 
</tr>

</table>
</form>


</div>
</body>

</html>

2. BoardController

	@RequestMapping("/getBoard.do") 
	public void getBoard(ExamVO vo, Model  model){	
		System.out.println("===> getBoard 확인");

		model.addAttribute("m", service.getExam(vo))	;
	}

 

결과)


delete.do 만들기

 

3. BoardController

	@RequestMapping("/delete.do") 
	public String delete(ExamVO vo, Model  model){	
		System.out.println("===> delete.do 확인");
		service.delete(vo);
		return "redirect:getBoardList.do";
	}

 

결과)

'SpringBoot' 카테고리의 다른 글

thymeleaf - getBoardList (날짜+합계)  (0) 2022.10.14
thymeleaf - getBoard 수정하기 + 순번  (0) 2022.10.14
thymeleaf - getBoardList 링크  (0) 2022.10.14
thymeleaf - getBoardList  (0) 2022.10.14
thymeleaf - hello  (0) 2022.10.14
Comments