thymeleaf从session中获取用户信息,thymeleaf从servletContext获取信息
时间:2019-11-08 00:34:35
收藏:0
阅读:2205
话不多说直接上代码
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>
原文:https://www.cnblogs.com/book-mountain/p/11817117.html
评论(0)