| Author |
How to compare request attribute in Jsp in struts2
|
gyanendra ojha
Greenhorn
Joined: May 16, 2007
Posts: 11
|
|
hi All, i want a compare a request attribute (say "actionName") that has been set in a Action class in a jsp with struts2 tag ( i.e </s:if> ) in a Struts2 application. but, my code is not working . please, check where i am wrong and suggest me right way to do it. i have also visited Struts2 documentation but was in vain. My Action :----> public class AboutProject extends ActionSupport { public String execute() throws Exception { String actionName=getActionName(); HttpServletRequest request = ServletActionContext.getRequest(); request.setAttribute("actionName", "edit"); return "SUCCESS"; } } My JSP :---> <s:if test="%{actionName}=='edit'"> <tr> <td> action is Edit </td></tr> </s:if> <s:else> <tr> <td> action is Not Edit </td></tr> </s:else>
|
 |
Ian Robinson
Greenhorn
Joined: Jul 16, 2008
Posts: 1
|
|
<s:if test="%{actionName}=='edit'"> will look in the root of the value stack - basically, you action. To reference the request you will need something like <s:if test="%{#request.actionName}=='edit'"> If memory serves me right!
|
 |
 |
|
|
subject: How to compare request attribute in Jsp in struts2
|
|
|