I am calling an action via foo.action?error=bar
In struts.xml
, I have configured the action chain as follows:
<action name="foo">
<interceptor-ref name="defaultStack"/>
<!-- custom interceptors -->
<result name="success">/jsp/foo.jsp</result>
</action>
In the JSP, I'm running a test:
<s:if test="#parameters.error[0] == 'bar'">
It's legacy code; this works.
However, the following does not, and I don't understand why:
<s:if test="#parameters.error == 'bar'">
Why do I need to pretend the error parameter is a collection?
Judging from the docs:
I shouldn't have to - but then I haven't used JSPs much...
I have added the following to the JSP, in order to help me understand what's going on:
<s:property value="#parameters.error"/> // bar
<s:property value="parameters.error"/> // <nothing>
<s:property value="parameters.error[0]"/> // <nothing>
<%= pageContext.getRequest().getParameter("error") %> // bar
<%= pageContext.getRequest().getParameter("error").getClass() %> // class java.lang.String
<s:property value="#parameters.error=='bar'"/> // false
<s:property value="'token'.getClass()"/> // <nothing>
That output confuses me even more. Can someone please explain what's going on?