diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java index e017e89f..b5b26e0e 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java @@ -1,6 +1,8 @@ package ${basePackage}.frame.utils; -import javax.servlet.http.Cookie; + import ${basePackage}.frame.auth.LocalData; + import javax.servlet.http.Cookie; + import javax.servlet.http.HttpServletRequest; /** * CookieUtil @@ -31,4 +33,18 @@ public class CookieUtil { } return null; } + + /** + * 生成一个默认的Cookie + * + * @param cookies Cookies + * @return passportID + */ + public static Cookie newCookie(String key, String value) { + HttpServletRequest request = LocalData.getRequest(); + Cookie cookie = new Cookie(key, value); + cookie.setDomain(request.getServerName()); + cookie.setPath(request.getContextPath()); + return cookie; + } }