In my application, I use Struts 2.
In one page, I want to use the Struts 2 <s:if> tag, but can’t get it to work.
In the action, I expose a “person” entity to the view.
Then in the page, I want to compare the current date with the person’s birthday.
I tried this:
<s:if test="person.birthday > new java.util.Date()">xxxx</s:if>
But it does not work.
How to fix it?
I believe that you are using
Dateas a data type forperson.brithday.You can do it as follows wayAdditionally using
java.util.Date()is not good practice at all since most of its method are deprecated so i suggest you to usejava.util.Calendarwhich is more flexible.You can use
Date.equals(), Date.before() and Date.after()to compare 2 dates.All you need to do something as followsWhere i am assuming that
currentDateis being set in your Action class, but if you want to change it to use it only in jsp page can change it.