일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- JPQL
- 스프링 핵심 기능
- 스프링
- AOP
- transaction
- 그리디
- Spring Boot
- pointcut
- Proxy
- 알고리즘
- db
- kotlin
- springdatajpa
- JDBC
- Greedy
- http
- SpringBoot
- QueryDSL
- 백준
- Exception
- 자바
- Servlet
- 스프링 핵심 원리
- spring
- jpa
- Android
- 김영한
- Thymeleaf
- java
- 인프런
- Today
- Total
목록@ResponseBody (3)
개발자되기 프로젝트
1. @PostMapping @RestController @RequestMapping("/api") class PostApiController { @PostMapping("/post-mapping") fun postMapping(): String{ return "post-mapping" } } 2. @RequestMapping 사용 시 @RequestMapping(method = [RequestMethod.POST], path = ["/request-mapping"]) fun requestMapping(): String { return "post-mapping2" } 3. @RequestBody HTTP 메세지 바디에 담겨있는 json data를 객체로 받기 위해서 @RequestBody 사용. HTTP..
https://github.com/bsh6463/MVC2HTTP API를 제공하는 경우 데이터를 전달해야함. 따라서 Message Body JSON형식으로 전달해야함. 1. HttpServletResponse 사용 writer를 가져와서 data를 message body에 넣음. @GetMapping("/response-body-string-v1") public void responseBodyV1(HttpServletResponse response) throws IOException { response.getWriter().write("ok"); } 2. ResponseEntity 사용 ResponseEntity를 사용하면 String을 MessageBody에 넣어줌.
1.HTTP message Body에 데이터를 직접 담아서 요청할 수 있음. HTTP API에서 주로 사용, JSON, XML, TEXT JSON 형식 POST, PUT, PATCH 요청 파라미터와 다르게 HTTP 메시지 바디에 데이터를 답아서 넘어오면 @RequestParam, @ModelAttribute를 사용할 수 없다. (단, HTML Form형식은 메시지 바디에 쿼리 파라미터 형태임 ㅋㅋ) 2. messageBody의 텍스트 꺼내기. inputStream 받기 : request.getInputStream() Stream을 String으로 바꾸기 StreamUtils에서 제공하는 copyToString()사용, stream은 바이트코드로 바이트코드를 문자로 변경할 때는 인코딩 방식 지정 필요. @..