If-then-else inside a JSP expression?

后端 未结 4 1452
臣服心动
臣服心动 2021-02-04 00:15

Can you do an if-then-else statement inside a JSP expression?

EDIT : Specifically I was looking for a JSP solution, not a JSTL solution. But some JSTL s

4条回答
  •  时光取名叫无心
    2021-02-04 00:49

    there is a different way I use because Eclipse keep telling me that it can't resolve a variable which is coming from the servlet while executing which is below (PS: Am new to JSP):

    ${if(var != null)"text to print"}
    ${if(var != null)var}  to print a variable 
    ${if(var != null)"text to print"}
    

    the result will be like

    text to print text to print

提交回复
热议问题