1.必要性 经常我们需要实现登录之后携带该登录者的账号信息进行操作,将会记录传值该携带者的信息,例如点击收藏,则session自动识别点击收藏的本人是谁,进而将相关数据存入数据库 2.设置 session 3.前端获取 <div type="hidden" name="user" th:text="${session.userSession.userName}"> </div>