본문 바로가기
Spring Boot/error

HttpMediaTypeNotAcceptableException

by 상국이 2022. 2. 27.
728x90
MockHttpServletRequest:
      HTTP Method = POST
      Request URI = /users/create
       Parameters = {}
          Headers = [Content-Type:"application/json;charset=UTF-8", Accept:"application/xml", Content-Length:"41"]
             Body = {"username":"sangguk", "password":"1234"}
    Session Attrs = {}

Handler:
             Type = com.example.springbootwebmvc.user.UserController
           Method = com.example.springbootwebmvc.user.UserController#create(User)

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = org.springframework.web.HttpMediaTypeNotAcceptableException

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 406
    Error message = null
          Headers = []
     Content type = null
             Body = 
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

java.lang.AssertionError: Status 
Expected :200
Actual   :406

 

 > 위의 경우 해당 View의 메시지 컨버터의 dependency를 추가해주면 해결된다.

728x90

댓글