반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 인프런인강
- 인프런무료강좌
- 자바스크립트파라미터
- .NET
- 제로초
- NPM
- Blazor
- 인프런강좌
- 틱택토구현
- 인프런자바스크립트
- 인프런
- 자바스크립트객체리터럴
- 고차함수
- 자바스크립트
- EntityFramework
- 객체의비교
- 자바스크립트함수
- slice
- HTTP
- 비주얼스튜디오
- 이벤트리스너
- 자바스크립트틱택토
- 인프런강의
- 자바스크립트recude
- 콜백함수
- sort
- 코딩
- c#
- 인터넷프로토콜
- 객체리터럴
Archives
- Today
- Total
샐님은 개발중
3. HTTP 요청 - 기본,헤더 조회 본문
728x90
반응형
1. HTTP 헤더 정보 조회
package hello.springmvc.basic.request;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpMethod;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Locale;
@Slf4j
@RestController
public class RequestHeaderController {
@RequestMapping("/headers")
public String headers(HttpServletRequest request,
HttpServletResponse response,
HttpMethod httpMethod,
Locale locale,
@RequestHeader MultiValueMap<String,String> headerMap,
@RequestHeader("host")String host,
@CookieValue(value="myCookie", required=false) String cookie){
log.info("request={}",request);
log.info("response={}",response);
log.info("httpMethod={}",httpMethod);
log.info("locale={}",locale);
log.info("host={}",host);
log.info("myCookie={}",cookie);
log.info("headerMap={}",headerMap);
return "ok";
}
}
결과
2023-07-10T17:27:27.858+09:00 INFO 29772 --- [nio-8080-exec-3] h.s.b.request.RequestHeaderController : request=org.apache.catalina.connector.RequestFacade@5dbffac5
2023-07-10T17:27:27.860+09:00 INFO 29772 --- [nio-8080-exec-3] h.s.b.request.RequestHeaderController : response=org.apache.catalina.connector.ResponseFacade@1c7e4d53
2023-07-10T17:27:27.860+09:00 INFO 29772 --- [nio-8080-exec-3] h.s.b.request.RequestHeaderController : httpMethod=GET
2023-07-10T17:27:27.860+09:00 INFO 29772 --- [nio-8080-exec-3] h.s.b.request.RequestHeaderController : locale=ko_KR
2023-07-10T17:27:27.860+09:00 INFO 29772 --- [nio-8080-exec-3] h.s.b.request.RequestHeaderController : host=localhost:8080
2023-07-10T17:27:27.860+09:00 INFO 29772 --- [nio-8080-exec-3] h.s.b.request.RequestHeaderController : myCookie=null
2023-07-10T17:27:27.861+09:00 INFO 29772 --- [nio-8080-exec-3] h.s.b.request.RequestHeaderController : headerMap={content-type=[application/json], user-agent=[PostmanRuntime/7.32.3], accept=[*/*], postman-token=[59ee67e0-9c97-4786-b000-fa0d52f3d695], host=[localhost:8080], accept-encoding=[gzip, deflate, br], connection=[keep-alive], content-length=[31]}
728x90
반응형
'스프링 MVC 1편 -인프런 김영한 > 섹션6-스프링MVC - 기본 기능' 카테고리의 다른 글
6. HTTP 요청 메시지 - 단순 텍스트 (0) | 2023.07.10 |
---|---|
5. HTTP 요청 파라미터 - @ModelAttribute (0) | 2023.07.10 |
4. HTTP 요청 파라미터 - 쿼리 파라미터, HTML Form (0) | 2023.07.10 |
2. 요청 매핑, 매핑 API (0) | 2023.07.10 |
1. 프로젝트 생성, 로그라이브러 (SLF4J) (0) | 2023.07.10 |