| Author |
s:if Question
|
David Ogasawara
Greenhorn
Joined: Oct 11, 2001
Posts: 13
|
|
I'm new to Struts 2 and I'm trying to figure out why my s:if is not working. If I enter this: it returns Y. However, if I enter this: It returns No. What am I doing wrong? [ May 23, 2008: Message edited by: David Martin ]
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
The expressions you are using are OGNL expresssions, not Java expressions. The expression "#{session.admin}" is a valid OGNL expression, while "#{session.admin.trim()}" is not.
|
Merrill
Consultant, Sima Solutions
|
 |
David Ogasawara
Greenhorn
Joined: Oct 11, 2001
Posts: 13
|
|
Thank you for your assistance. However, I changed the code and it still gives me the incorrect response. Could the problem be that I'm comparing a String to a char? If so, how is this solved?
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
The condition goes inside the brackets. try
|
 |
David Ogasawara
Greenhorn
Joined: Oct 11, 2001
Posts: 13
|
|
|
Thank you for your help! I figured out the problem. I initially set the session variable as a String (session.setAttribute("admin", "Y")). Changing it to a char (session.setAttribute("admin", 'Y')) solved the problem.
|
 |
 |
|
|
subject: s:if Question
|
|
|