고민, 나중에..
Delete시 id값 파라미터는 int? String? 상관없었다.
지각생
2022. 2. 7. 14:23
728x90
let index = {
init: function () {
$("#btn-saveTheWriting").on("click", () => {
this.saveTheWriting();
});
$("#btn-delete").on("click", () => {
this.deleteById();
});
deleteById: function () {
let no = "";
$("input[name=no]:checked").each(function () {
var no = $(this).attr("value");
console.log(no);
$.ajax({
type: "DELETE",
url: "/board/detail/" + no,
data: JSON.stringify(no),
})
.done(function (resp) {
alert("글삭제가 완료되었습니다.");
location.href = "/";
})
.fail(function (error) {
alert(JSON.stringify(error));
});
});
},
@DeleteMapping("/board/detail/{no}")
public ResponseDto<Integer> deleteWriting(@PathVariable int no) {
System.out.println("numbers"+no);
boardService.deleteWritingList(no);
return new ResponseDto<Integer>(HttpStatus.OK.value(), 1);
}
여기서 @PathVariable int no?
@PathVariable String no?
문제 없이 다 글 삭제가 가능했다.
<delete id="deleteWritingList">
DELETE FROM board WHERE no =${no}
</delete>
728x90