import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class RequestHeaderExampleController{
@RequestMapping(value = "/example", method = RequestMethod.GET)
public String getHello(@RequestHeader ("host") String hostName,
@RequestHeader ("Accept") String acceptType,
@RequestHeader ("Accept-Language") String acceptLang,
@RequestHeader ("Accept-Encoding") String acceptEnc,
@RequestHeader ("Cache-Control") String cacheCon,
@RequestHeader ("Cookie") String cookie,
@RequestHeader ("User-Agent") String userAgent){
System.out.println("Host : " + hostName);
System.out.println("Accept : " + acceptType);
System.out.println("Accept Language : " + acceptLang);
System.out.println("Accept Encoding : " + acceptEnc);
System.out.println("Cache-Control : " + cacheCon);
System.out.println("Cookie : " + cookie);
System.out.println("User-Agent : " + userAgent);
return "example";
}
}