728x90
해결
JSP
<input id="title" />
자바스크립트
title:$("#title").val()
saveTheWriting: function () {
let data = {
title: $("#title").val(),
content: $("#summernote").val(),
categoryName: $("#categoryName").val(),
channelName: $("#channelName").val(),
};
console.log("saveTheWriting", data);
$.ajax({
type: "POST",
url: "/board/saveTheWritingForm",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
})
.done(function (resp) {
alert("글쓰기가 완료되었습니다.");
history.back();
})
.fail(function (error) {
alert(JSON.stringify(error));
});
JSP
<input class="title" />
자바스크립트
title:$(".title").val() 로 변경
saveTheWriting: function () {
let data = {
title: $(".title").val(),
content: $("#summernote").val(),
categoryName: $("#categoryName").val(),
channelName: $("#channelName").val(),
};
console.log("saveTheWriting", data);
$.ajax({
type: "POST",
url: "/board/saveTheWritingForm",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
})
.done(function (resp) {
alert("글쓰기가 완료되었습니다.");
history.back();
})
.fail(function (error) {
alert(JSON.stringify(error));
});
현상
제목(title)이 1212 값을 가졌지만
로그를 보면 채널값을 가져옴
특이한 점은 Uri가 channel관련된 곳에서 글을 쓸때만 오류가 발생한다.
그리고 처음에는 channel관련된 곳에서도 잘 되었다.
아마 코드를 첨가하면서 어느 시점 이후로 문제가 생긴거 같은데
그래도 자바스크립트에서 id값이 아닌 class값가져오는 걸로 해결 되서 다행이다.
728x90
'Spring (boot) 오류 해결' 카테고리의 다른 글
MyBatis 오류: Invalid bound statement (not found) (0) | 2022.02.24 |
---|---|
Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/MyBlog/Dto/Board (wrong name: (0) | 2022.02.23 |
스프링 URI 한글 깨짐 문제 (0) | 2022.02.20 |
JSP 날짜 변환 에러(게시판, 오늘 게시글 날짜 구분하기) (0) | 2022.02.19 |
JSTL if문 학습 (0) | 2022.02.18 |
댓글