From efdb99f8cecc4afb592afad79c761081d5d5cf22 Mon Sep 17 00:00:00 2001
From: lee <4766465@qq.com>
Date: Wed, 18 Dec 2024 13:27:00 +0800
Subject: [PATCH] init

---
 xxl-job/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/xxl-job/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java b/xxl-job/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java
new file mode 100644
index 0000000..592d496
--- /dev/null
+++ b/xxl-job/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java
@@ -0,0 +1,42 @@
+package com.xxl.job.admin.controller.interceptor;
+
+import com.xxl.job.admin.core.util.FtlUtil;
+import com.xxl.job.admin.core.util.I18nUtil;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.AsyncHandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+
+/**
+ * push cookies to model as cookieMap
+ *
+ * @author xuxueli 2015-12-12 18:09:04
+ */
+@Component
+public class CookieInterceptor implements AsyncHandlerInterceptor {
+
+	@Override
+	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
+			ModelAndView modelAndView) throws Exception {
+
+		// cookie
+		if (modelAndView!=null && request.getCookies()!=null && request.getCookies().length>0) {
+			HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
+			for (Cookie ck : request.getCookies()) {
+				cookieMap.put(ck.getName(), ck);
+			}
+			modelAndView.addObject("cookieMap", cookieMap);
+		}
+
+		// static method
+		if (modelAndView != null) {
+			modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
+		}
+
+	}
+	
+}

--
Gitblit v1.9.3