본문 바로가기

Spring53

Response 내려주기 응답하는 방법은 두가지로 나뉘어 진다. 데이터형식으로 응답하는 형태: @RestController 어노테이션 사용 페이지형식(HTML 등)으로 응답하는 형태: @Controller 어노테이션 사용 테스트 진행을 위한 DTO 생성 @JsonInclude을 사용하면 데이터를 응답할 때 null 값을 제외하고 보낼 수 있다. int형을 Integer로 변경하면 기본값이 0에서 null값으로 변경된다. package com.example.response.dto; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databin.. 2021. 6. 12.
Delete API 리소스 삭제, 멱등성, PathVariable, Query Parameter Delete는 Dto를 이용해서 작성하는 것보다 Query Parameter를 전달받아 처리하는 것을 권장한다. 예제 package com.example.delete.controller; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api") public class DeleteApiController { @DeleteMapping("/delete/{userId}") public void delete(@PathVariable String userId, @RequestParam String account){ System.out... 2021. 6. 12.
PUT API 리소스 갱신/ 생성, 멱등성, Path Variable, DataBody, Query Parameter Json 디자인 { "name" : "", "age" : , "car_list" : [ { "name" : "", "car_number" : "" }, { "name" : "", "car_number" : "" } ] } 예제 dto 작성 package com.example.put.dto; import com.fasterxml.jackson.annotation.JsonProperty; public class CarDto { private String name; // 받을 JSON key값 직접지정 @JsonProperty(value = "car_number") private String carNumbe.. 2021. 6. 12.
Post API 리소스 생성, 추가, create, Path Variable, Query Parameter, DataBody XML, JSON 형태로 데이터를 전달 주로 JSON으로 전달 타입 string : value number : value boolean : value object : vlaue { } array : value [ ] JSON 포맷 { "phone_number" : "value", "phoneNumber" : "value", "string" : "010-222-3333" "number" : 10, "boolean" : false, "object" : { "address" : "aaa@naver.com", "password" : "aaaa" }, "array" : [ { "account" : "abc.. 2021. 6. 12.
Get API Get API: 리소스 취득, Read, 멱등성, 안정성, Path Variable, Query Prarameter 코드 작성 일반적인 방법 package com.example.hello.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/.. 2021. 6. 12.
Hello World API 만들기 Rest Cilent 설치 구글 검색(크롬 웹스토어) https://chrome.google.com/webstore/category/extensions?hl=ko& Chrome 웹 스토어 Chrome에 사용할 유용한 앱, 게임, 확장 프로그램 및 테마를 찾아보세요. chrome.google.com 검색: rest api client Talend API Tester - Free Edition -> Chrome 에 추가 https://chrome.google.com/webstore/detail/talend-api-tester-free-ed/aejoelaoggembcahagimdiliamlcdmfm?hl=ko& Talend API Tester - Free Edition Visually interact with.. 2021. 6. 12.