|
@@ -1,7 +1,42 @@
|
|
|
package com.sf.sysdemo.controller;
|
|
|
|
|
|
+import jakarta.servlet.ServletContext;
|
|
|
+import jakarta.servlet.ServletException;
|
|
|
import jakarta.servlet.annotation.WebServlet;
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import jakarta.servlet.http.HttpSession;
|
|
|
+import org.thymeleaf.TemplateEngine;
|
|
|
+import org.thymeleaf.context.WebContext;
|
|
|
+import org.thymeleaf.web.servlet.IServletWebExchange;
|
|
|
+import org.thymeleaf.web.servlet.JakartaServletWebApplication;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Random;
|
|
|
|
|
|
@WebServlet("/schedule/*")
|
|
|
public class ScheduleController extends BaseController {
|
|
|
+
|
|
|
+ public void info(HttpServletRequest req, HttpServletResponse resp)
|
|
|
+ throws ServletException, IOException {
|
|
|
+ ServletContext servletContext = req.getServletContext();
|
|
|
+ TemplateEngine engine = (TemplateEngine)servletContext.getAttribute("engine");
|
|
|
+ JakartaServletWebApplication application = (JakartaServletWebApplication)
|
|
|
+ servletContext.getAttribute("application");
|
|
|
+
|
|
|
+ resp.setCharacterEncoding("UTF-8");
|
|
|
+
|
|
|
+ HttpSession session = req.getSession();
|
|
|
+ String username = (String)session.getAttribute("username");
|
|
|
+ req.setAttribute("message", "Hello " + username);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ IServletWebExchange webExchange = application.buildExchange(req, resp);
|
|
|
+
|
|
|
+ WebContext webContext = new WebContext(webExchange);
|
|
|
+
|
|
|
+
|
|
|
+ engine.process("index", webContext, resp.getWriter());
|
|
|
+ }
|
|
|
}
|