From a05953ec758924971da06825cc129276da2565e0 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 16 Apr 2020 01:53:25 +0800 Subject: [PATCH] update --- .../java/com/yutou/tools/utils/Tools.java | 15 +++++++ .../com/yutou/tools/web/userController.java | 23 +++++++++++ web/html/body/nas.html | 31 ++++++++------- web/index.html | 39 +++++++++++++------ 4 files changed, 82 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/yutou/tools/utils/Tools.java create mode 100644 src/main/java/com/yutou/tools/web/userController.java diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java new file mode 100644 index 0000000..c9b0100 --- /dev/null +++ b/src/main/java/com/yutou/tools/utils/Tools.java @@ -0,0 +1,15 @@ +package com.yutou.tools.utils; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; + +public class Tools { + public static Cookie getCookie(HttpServletRequest request,String key){ + for (Cookie cookie : request.getCookies()) { + if(cookie.getName().equals(key)){ + return cookie; + } + } + return null; + } +} diff --git a/src/main/java/com/yutou/tools/web/userController.java b/src/main/java/com/yutou/tools/web/userController.java new file mode 100644 index 0000000..f923665 --- /dev/null +++ b/src/main/java/com/yutou/tools/web/userController.java @@ -0,0 +1,23 @@ +package com.yutou.tools.web; + +import com.alibaba.fastjson.JSONObject; +import com.yutou.tools.utils.Tools; +import org.springframework.stereotype.Controller; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; + +@Controller +public class userController { + + public String getLoginState(HttpServletRequest request){ + JSONObject json=new JSONObject(); + Cookie cookie= Tools.getCookie(request,"user"); + if(cookie==null){ + json.put("code",-1); + json.put("msg","未登录"); + return json.toJSONString(); + } + return ""; + } +} diff --git a/web/html/body/nas.html b/web/html/body/nas.html index acd546d..f0ac369 100644 --- a/web/html/body/nas.html +++ b/web/html/body/nas.html @@ -1,21 +1,24 @@ -
- - -