Freemarker表达式获取session中的值

1.在session中保存userId的值

request.getSession().setAttribute("userId",userId);

2.在页面使用freemarker表达式,如果userId的值是空就会报错,所以要先判断一下

<#if Session["userId"]?exists>
 ${Session["userId"]}
  </#if>
发布了25 篇原创文章 · 获赞 4 · 访问量 1517

猜你喜欢

转载自blog.csdn.net/weixin_39025362/article/details/105091630