Conditional if in struts2 tags
I have the following code.
<s:push value="#session['person']">
<s:if test="%{ad开发者_StackOverflowmin=='y'}">
<a class="add" href="/projit1/project/addProject.jsp">Create a Project</a>
</s:if>
</s:push>
I am trying push an object person from session map to valuestack and check one of its properties admin's value. If it is 'y' then the link "create a project" appears.
But this code is not working. If i use the above code, both admins and normal members does not see the link. what could be the problem ? please help
Try this.
<s:push value="person">
<s:if test="%{admin=='y'}">
<a class="add" href="/projit1/project/addProject.jsp">Create a Project</a>
</s:if>
</s:push>
And you have a getAdmin()
or isAdmin()
on your Person object I assume? If that's the case, I also assume the method returns a char
'y'? I suggest you try displaying the result of calling admin and go from there. e.g.
<s:push value="#session['person']">
admin: <s:property value="%{admin}" />
<s:if test="%{admin=='y'}">
<a class="add" href="/projit1/project/addProject.jsp">Create a Project</a>
</s:if>
</s:push>
精彩评论