@Slf4j
@RestController
@CrossOrigin
public class LoginController {
@GetMapping("/c1")
public Result cookie1(HttpServletResponse response){
response.addCookie(new Cookie("Login_user","zwj"));
return new Result().success();
}
@GetMapping("/c2")
public Result cookie2(HttpServletRequest request){
Cookie[] cookies=request.getCookies();
for(Cookie cookie:cookies){
if(cookie.getName().equals("Login_user")){
System.out.println("Login_user: "+cookie.getValue());
}
}
return new Result().success();
}
}
标签:cookie,java,后端,Cookie,Result,new,public,user From: https://www.cnblogs.com/luo9tian/p/17963806