Search code examples
javajspstruts2struts-tags

Why <s:if test> tag isn't working correctly?


I've set a value in session (something) , now i can't use that in struts if tag

<s:if test=%{#session.key == 'something'}>
    // 'some code'
</s:if>

'some code' never runs.. but i can reach that specific value from the same key in the session in property tag correctly.

<s:property value="#session.key" />

any help ?

Thanks.


Solution

  • Finally i got solution. problem is : the key which is in the session object is not a string and should be convert to string .

    solution i found is : using StrutsTypeConverter for that value in a seperate class then, override two methods convertToString, convertFromString and do define xwork-conversion.properties file under WEB-INF/classes folder (configurations) and put key = convertorClassNamein it. so struts will automatically do conversion when needed.

    if you have any easier solution for type casting, i'll be happy =)

    Thanks!