[ ReplyController ]

@DeleteMapping("/{id}")
public void replyDELETE(@PathVariable("id") int reply_no) {
    replyService.delete(reply_no);
}

- path의 id = @어노테이션 id는 이름이 같아야한다.

- reply_no는 url에 붙는 값

 

 

 

[ get.html ]

댓글 삭제 버튼 태그에 추가하기

onclick="deleteReply(this)" data-id="${id}"
 

그 다음 deleteReply() 함수 만들기

//댓글 삭제버튼
function deleteReply(el){
    if(confirm('정말 삭제하시겠습니까?')){
        http
            .delete('/reply'+el.dataset.id)
            .then((res) => console.log(res))
            .catch((err) => console.log(err));
        el.parentElement.parentElement.remove();
    }
}

 

 

 

 

 

반응형
LIST

+ Recent posts