spring mvc : http request - header
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
package com.example.springmvc.basic.request;
|
||||||
|
|
||||||
|
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 javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
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("headerMap={}", headerMap);
|
||||||
|
log.info("header host={}", host);
|
||||||
|
log.info("myCookie={}", cookie);
|
||||||
|
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package com.example.springmvc.basic.requestmapping;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/mapping/users")
|
@RequestMapping("/users")
|
||||||
public class MappingClassController {
|
public class MappingClassController {
|
||||||
/**
|
/**
|
||||||
* GET /mapping/users
|
* GET /mapping/users
|
||||||
|
|||||||
Reference in New Issue
Block a user