package com.example.demo.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.google.gson.JsonObject; @RestController public class TestController{ @RequestMapping(value = "/", method = RequestMethod.GET) public String test(@RequestParam("id") String id){ JsonObject obj = new JsonObject(); obj.addProperty("title", "산사와 아가싸"); obj.addProperty("content", "로맨틱 코메디"); JsonObject data = new JsonObject(); data.addProperty("time", "토일 8시"); obj.add("data", data); return obj.toString(); } }