話不多說直接上代碼
session
后端代碼:
//創建session對象 HttpSession session = request.getSession(true); session.setAttribute("USER_INFO",userInfo);//把用戶數據保存到session對象中
前端代碼:
<span class="x-red" th:text="${session.USER_INFO.uName}"/>
servletContext
后端代碼:
servletContext.setAttribute("COUNT",val);
前端代碼:
<cite th:text="${#servletContext.getAttribute('COUNT')}">99</cite>
