In my Struts2 project returned a List<Object> from my java action class. One of the data members in the objects is a date in long form (from MySQL database). I am not authorised to make changes to the class structure or database. I need to output this date as human readable.
I want to implement:
<% Date mydate = new Date (long dateAsLong); %>
<%= mydate.toString() %>
Here dateAsLong is data member of the objects returned.
I need this help as I have to apply it to other cases as well. Like I have to check the variables in JSP itself using:
<s:if test='<s:property value="priority"/> == 1'>
/*Some img to display here*/
</s:if>
I am a newbie and want to use plain struts2 and JSP. Please just help me know how I can access that variable returned in <s:property/>.
Thanks.
The
<s:set/>tag places values on to the ValueStack, which isn’t conveniently available from scriptlets (I would recommend you avoid scriptlets anyway).First, on the subject of:
Try this:
You can also use JSP EL:
As for the date, asdoctrey mentioned, you could do this conversion in your action class. I’ve handled this in the past using a custom JSP function.
The TLD
The Java
The JSP