Spring18 Response 데이터와 JSON 포맷 실습 UserDto JavaClass package com.eom.controllerexercise.dto; import java.util.List; public class UserDto { Integer id; String name; String email; List specialties; public UserDto(Integer id, String name, String email, List specialties) { this.id = id; this.name = name; this.email = email; this.specialties = specialties; } public Integer getId() { return id; } public String getName() { return name; .. 2024. 3. 20. Response 데이터와 JSON 포맷 JSON 응답 데이터 · 웹 개발 시 가장 일반적으로 사용하는 응답 데이터 포맷 · 프론트엔드에서는 JSON 형식의 데이터를 응답 받아 화면을 구성 · 각 REST API 별로 어떤 JSON 데이터를 응답할 것인지 사전에 정함 - 프론트엔드와 백엔드 모두 정해진 JSON 데이터에 맞게 구현 JSON · JSON - JavaScript Object Notation · JSON는 데이터를 교환하는 데 사용 · 기존의 방법(XML) 보다 가벼움 · XML에 비해 상대적으로 사람이 읽고 이해하기가 쉬움 JSON 문법 · JSON 객체(Object)가 가장 기본 단위로 "key":value 데이터를 포함 - JSON 객체의 시작과 끝은 중괄호 ({})를 사용 - key는 큰타옴표 ("")로 묶음 - value에는.. 2024. 3. 20. Request 파라미터 실습 package com.eom.controllerexercise.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController public class RequestParamController { @RequestMapping(value = "/post") public String getPost(@RequestParam(name = "category") String category, @Requ.. 2024. 3. 20. RequestMapping과 URI 실습 package com.eom.controllerexercise.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class UserController { @RequestMapping(value = "/user/paid") public String getPaidUser() { return "I'm a paid user."; } @RequestMapping(value = "/user/enterprise") public String getEnterpriseUser() { re.. 2024. 3. 19. 이전 1 2 3 4 5 다음