If-then-else inside a JSP expression?

后端 未结 4 1440
臣服心动
臣服心动 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:58

    In JSP EL 2.0, you can do that using the ternary operator. For instance:

    
    

    What it does is it checks JSP's param's number variable. If it's 1, then selected is substituted. otherwise, nothing.

提交回复
热议问题