목록강의수강 (42)
미소를뿌리는감자의 코딩
이번에는 json 형식으로 반환하는 방법에 대해서 알아보았다. 2가지 방법을 소개할 것인데, 하나는 직접 json 형태로 바꾸어주고 반환하는 방법이고, 다른 하나는 spring이 class를 json 형태로 변환하여 반환하는 방법이다. 1) 직접 json 형태로 바꾸어주고 반환하는 방법 // Content- Type: text/html // Response Body // {"name" : "Robbie", "age":95} 로 client에게 반환 @GetMapping("/json/string") @ResponseBody public String helloStringJson() { return "{\"name\":\"Robbie\",\"age\":95}"; } Context- Type은 text/html..

정적 html은 resouces > static 폴더에 넣어주는 것이 일반적이며, 동적 html은 templates > hello.html 폴더에 넣어주는 것이 일반적이다. 이때, url에 대해서 html 파일을 불러오는 방법을 이야기해 볼 것이다. 1. 정적 html 아래 3가지 방법이 있다. @Controller public class HtmlController { @GetMapping("/static-hello") public String hello(){ return "hello.html"; } @GetMapping("/html/redirect") public String htmlStatic() { return "redirect:/hello.html"; } @GetMapping("/html/temp..
@RestController RESTful 웹 서비스 형성을 간소화 하기 위해서 적는 annotation이다. @RestController = @Controller + @ResponseBody 이다. @Controller web request가 도달할 수 있는 종착역 @ResponseBody HttpMessageWriter를 통해서, 반환하는 것을 직렬화 (serialize) 즉 client에게 response를 보내는 본문 @GetMapping("/hello") Get의 HTTP request 처리 @PostMapping("/hello") Post의 HTTP request 처리 @PutMapping("/hello") Put의 HTTP request 처리 @DeleteMapping("/hello") De..
command + , 설정 shift 2번 libraries 추가 tab, file 검색 command + 1 왼쪽 tab 켜고 끄기 command + n 해당 위치에서 새로운 것 만들기 option + enter unidentified에 대해서 여러 option을 보여줌. undefined class를 만드는 데에도 도움을 줌. command + e 최근에 보던 파일로 돌아갈 수 있음. 왔다갔다 하기 좋다 sout + enter System.out.println의 단축키 soutv + enter 위에 사용한 field를 자동으로 잡아줌. command + w 보던 창을 끄기 command + option + l 코드 정렬