How to get access to HTTP header information in Spring MVC REST controller?

前端 未结 3 601
我在风中等你
我在风中等你 2020-11-30 23:41

I am new to web programming in general, especially in Java, so I just learned what a header and body is.

I\'m writing RESTful services using Spring MVC. I am able to

3条回答
  •  伪装坚强ぢ
    2020-12-01 00:30

    My solution in Header parameters with example is user="test" is:

    @RequestMapping(value = "/restURL")
      public String serveRest(@RequestBody String body, @RequestHeader HttpHeaders headers){
    
    System.out.println(headers.get("user"));
    }
    

提交回复
热议问题