• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

질문드립니다.

19.05.06 13:27 작성 조회수 499

0

강좌보고 공부하면서 혼자 코딩을 하던중에 

ajax를 이용해서 게시판 등록을 해봤는데요 

   var formData = $("#replyForm").serializeObject();

          console.log(formData);

    $.ajax({

        type: "POST",

        contentType : "application/json; charset=utf-8",  

        url: "/replyWriteAction",

        data: formData,

        dataType: 'json',

        cache: false,

        timeout: 600000,

        success: function (data) {

                      },

        error: function (e) {

        }

컨트롤러 파일입니다 .

@RequestMapping(value = "/replyWriteAction", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })

public void replyWriteAction(@ModelAttribute Comment comment)

{

logger.debug("!>>55555555555555555>>>>>>"+comment.toString());

}

 

ajax 통신을 했는데 

There was an unexpected error (type=Bad Request, status=400).
Required request body is missing: public void com.sakumall.com.controller.BoardController.replyWriteAction(com.sakumall.com.entities.Comment)
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public void com.sakumall.com.controller.BoardController.replyWriteAction(com.sakumall.com.entities.Comment)
이렇게 에러가 발생하네요 ..해결책을 좀 알수있을까요 ?
 
github 주소입니다 .
ajax통신 부분 파일
html => board.html
server => BoardController.java
 
입니다 ..

답변 1

답변을 작성해보세요.

1

코드를 잘못 올리신거 같네요. java 파일을 올리셔야 하는데 class 파일을 올려두셔서 코드가 안보이네요.
그리고 에러 메시지를 잘 읽어 보시면 힌트를 좀 얻을 수 있지 않을까요?

Required request body is missing

이런 메시지가 있는걸 보니 Comment에 해당하는 데이터가 제대로 넘겨오지 않았거나 적절한 형태로 넘어오질 않은거 같네요. 요청에 실려오는 입력 데이터를 확인해 보세요.