2014年1月20日 星期一

Struts2 if tag for string and char comparison

Explanation: 
There are tow tag using in charater: String , character , and there are different in judge, if you using the character you will get false:


Result:
1. String example for work
 
<s:set name="webFramework" value="framework"/>
<s:if test="%{#webFramework=='Struts 2'}">
    This is Struts 2
</s:if>
<s:elseif test="%{#webFramework=='Struts 1'}">
    This is Struts 1
</s:elseif>
<s:else>
    Other framework
</s:else>

2. Character for work
<s:if test='%{#session.IsLogin== ("T")}'>
    Login
</s:if>
<s:else>
    LogOut
</s:else>




Reference:
String compare
character compare


























沒有留言:

張貼留言