Apache Struts 2 Documentation > Home > FAQs > why doesnt the if tag evaluate params properly
Added by Musachy Barroso, last edited by Musachy Barroso on May 28, 2008

try either

 <s:if test="%{#parameters.search[0] == 'something'}">
   ....
 </s:if>

or

 <s:if test="#parameters.search[0] == 'something'">
   ....
 </s:if>

Why to use search [ 0 ]?

The reason is that #parameters would return a Map, the framework conveniently makes request parameters into a Map to make unit testing action easier and the framework also uses

 request.getParameterMap();

which returns a Map where the key is the parameter (String) while the value is an array of the parameter value (Array of String), hence the need to use [ 0 ].