I have been given the following code of a JSP page that uses the Struts2 framework
<s:form id="crud" action="crudmerge" namespace="templates">
<s:hidden name="crudMode" />
<s:hidden name="item.id" />
...
<s:if test="crudMode == 1">
...
</s:if>
<s:else>
<s:if test="%{version != null}">
...
</s:if>
<s:else>
...
</s:else>
</s:else>
</s:form>
in the action class that results in this JSP page, there is the following methods (among others): getCrudMode()
, getItem()
, and item has a method called getId()
.
I understand how struts2 will use those methods to fill in the <s:hidden>
tags. I'm having problems however with the following line:
<s:if test="%{version != null}">
First, I thought this worked the same as the other two, and Struts2 would run the getVersion()
method of the action class. However, there is no field called version
and no method getVersion()
. There is also no <s:set name="version">
variable tag in the JSP. What could possibly be the point of this code? Are the %{}
really necessary?
It is possible this is legacy code that needs to be removed, but I'm not sure what the difference is between the first two crudmode
and item.id
and the latter %{version}
.