Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- katalon 비교
- 한국투자증권 해외주식 양도세
- 피보나치함수
- 국세청 해외주식 양도세 신고방식
- katalon xpath
- 재귀 예제
- javascript 자동완성
- 피보나치 예제
- git 연동
- 해외증권 양도세 한국투자증권
- 피보나치함수 예제
- katalon
- katalon 사용법
- 톰캣 실시간 로그
- Katalon Recorder 사용법
- js 자동완성
- recursion example
- bfs 미로탐색 java
- 테스트 자동화
- katalon 자동화
- 재귀함수 예제
- 주식 양도세 신고방법
- 홈택스 해외주식 양도세
- CSTS 폭포수 모델
- oracle group by
- java.sql.SQLSyntaxErrorException
- 해외주식 양도세 신고
- tomcat log
- 한국투자증권 양도세 신고
- 최대공약수 예제
Archives
- Today
- Total
엄지월드
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation 본문
카테고리 없음
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
킨글 2022. 9. 2. 08:59REST API 만들때 아래와 같은 에러를 만났다.
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
이유는 return ResponseEntity.ok().body()에서 데이터 하나밖에 넘겨줄 수 밖에 없기 때문에
return ResponseEntity.ok.body("test");와 같이 넘겨주면 작동하지만
return ResponseEntity.ok.body(responseResult);로 넘겨주면 작동하지 않고 위에 에러가 발생하는 것이었다.
즉, 핸들러 입장에서 클라이언트가 요청한 타입으로 응답을 내려줄 수 없는 에러였다.
package com.gworld.manage.controller;
import com.gworld.manage.common.model.ResponseResult;
import com.gworld.manage.model.BoardDto;
import com.gworld.manage.model.ServiceResult;
import com.gworld.manage.service.NoticeService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor
@RestController
public class ApiNoticeController {
private final NoticeService noticeService;
@PostMapping("/api/notice/del.api")
public ResponseEntity<?> del(
@RequestBody BoardDto boardDto
){
ServiceResult result = noticeService.delete(boardDto.getId());
if(!result.isResult()){
ResponseResult responseResult = new ResponseResult(false, result.getMessage());
return ResponseEntity.ok().body(responseResult);
}
ResponseResult responseResult = new ResponseResult(true);
return ResponseEntity.ok().body(responseResult);
}
}
그래서 ResponseResult에 @Data를 추가해주어 Getter를 처리하였다.
package com.gworld.manage.common.model;
import lombok.Data;
@Data
public class ResponseResult {
ResponseResultHeader header;
Object body;
public ResponseResult(boolean result, String message){
header = new ResponseResultHeader(result, message);
}
public ResponseResult(boolean result){
header = new ResponseResultHeader(result);
}
}
Comments