我是struts2的新手,正在尝试使用动态会话密钥检索会话对象。
我的应用程序流程如下:用户将从浏览器中点击操作
http://localhost:8080/prjcr/[email protected]
在操作类中,我使用[email protected]请求参数从web服务检索值列表,并将其存储在会话中,如下所示:
//get the request parameter
userid=ServletActionContext.getRequest().getParameter("userid);
QDefn[] qDefn = proxy.getQDefns(userid); //webservice call
List<QDefn> qdList = new ArrayList<QDefn>();
qdList.add(Arrays.asList(qDefn));
提取请求参数的userid部分,用作会话密钥
userid = userid.substring("UserId", userid.substring(0, userid.indexof( @ ));
//The key itself is what we receive in the request parameter
ActionContext.getContext().getSession().put("UserId", userid);
然后将关联的值列表推入会话
ActionContext.getContext().getSession().put(userid, qdList);
并转发到一个JSP,该JSP在选择下拉菜单中显示此列表,如下所示:
<s:select name="qdefn"
id="qdefn"
list="#session.%{#session.UserId}" ---What is the notation here??
listKey="defnName"
listValue="defnName"
headerKey="ALLQD"
headerValue="All" > </s:select>
I ve tried to pull the qdList from the session in jsp using a dynamic session key which is the userid. In java, we do it as session.get(userid). I am not able to get in terms with the OGNL notation yet. So, I dont know how to do it in Struts2/OGNL.
提前感谢