Reputation: 35
I have created a UserSession dto object and added many fields in that like lastloginTime
,lastAccessedTime
, userName
etc.
I want to display these in jsp using OGNL concept of Struts2
I have written
<li class="current_page_item"><b>Last Login Time <s:property value="#session.USROBJECT"/> </b></li>
In action, I have written
sessionMap.put("USROBJECT", us);
I am getting the object on jsp, but I want to display its fields.
Upvotes: 2
Views: 943
Reputation: 1
The #session
object is always available from the value stack
<s:property value="#session.USROBJECT.lastloginTime"/>
<s:property value="#session.USROBJECT.lastAccessedTime"/>
<s:property value="#session.USROBJECT.userName "/>
You should create getters for fields lastloginTime
,lastAccessedTime
, userName
etc.
Details and references you can find here.
But sessionMap
you should inject with the SessionAware
interface implemented by the action class. It's a preferable method.
You can see here how to implement SessionAware
interface.
Upvotes: 2