struts2 jsp 获取 Session


/*
   * 这个待会在页面用 <s:property value="#session.name"> 获取不到值
   * 只能用<%  String name=(String)session.getAttribute("name"); %><%=name %>
   */
  //ServletActionContext.getRequest().getSession().setAttribute("name","sessionName");
  
  
  //这个可以用 <s:property value="#session.name">获取到值
  ActionContext actionContext = ActionContext.getContext();
    Map session = actionContext.getSession();
    session.put("name", "SessionName");
发布了20 篇原创文章 · 获赞 2 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/u010947651/article/details/42566885