1234567891011121314151617181920 |
- package com.sf.eurekaclientdemo2.controller;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestHeader;
- import org.springframework.web.bind.annotation.RestController;
- @RestController
- public class HeaderController {
- /**
- * @param token
- * @return
- * @RequestHeader 可以直接从请求头中拿到对应key的值 注入到参数中
- */
- @GetMapping("/token")
- public String token(@RequestHeader("token") String token) {
- System.out.println("handler token: " + token);
- return "Token Success";
- }
- }
|