编写需要cookie才能访问的接口
这个接口还是在MyGetMethod类里面编写方法
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 | 
 
 
 @RequestMapping(value = "/get/with/cookies", method = RequestMethod.GET)
 @ApiOperation(value = "要求客户端携带cookie访问", httpMethod = "GET")
 public String getWithCookies(HttpServletRequest request){
 Cookie[] cookies = request.getCookies();
 if(Objects.isNull(cookies)){
 return "你必须携带cookies信息来";
 }
 for(Cookie cookie : cookies){
 if(cookie.getName().equals("login") && cookie.getValue().equals("True")){
 return "恭喜你,访问成功!,这是一个需要携带cookies信息才能访问的get请求";
 }
 }
 return "你必须携带cookies信息来";
 }
 
 |