---
title: "Struts获取Session"
author: "xiajin2080"
date: "2009-02-10T11:29:48Z"
tags: []
slug: "struts-session"
draft: false
lastmod: "2009-02-10T11:33:05Z"
id: 326085
url: "https://xiajin2080.iteye.com/blog/326085"
---

```java
1.
    Map session=ActionContext.getContext().getSession();
    session.put("xiajin", "test");
2.
    HttpSession httpSession=ServletActionContext.getRequest().getSession();
    httpSession.setAttribute("test", "jin");

    <s:property value="#session.xiajin"/> <br>
    <c:out value="${test}"></c:out>
```