Home  >  Q&A  >  body text

java - el表达式 if else

jsp模板标签,有if else的写法吗?
网上查了说这样写


刚学java,确定下只能这样写吗?感觉好别扭!
或者说有没有其他写法,
如果只有这样的写法,
那么

if(){

}elseif(){

}elseif(){
}

这样的情况怎么表示?

PHP中文网PHP中文网2741 days ago507

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:02:32

    means this

     <c:choose>
        <c:when test="${1==2}">
                 0001
        </c:when>
           <c:otherwise>
              <c:choose>
                <c:when test="${1==3}">
                 0002
                 </c:when>
                <c:otherwise>
                 0003
                 </c:otherwise>
            </c:choose>
         </c:otherwise>
    </c:choose>

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:02:32

        if(){
        
        }elseif(){
        
        }elseif(){
        }

    Isn’t this pattern just three c:ifs

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 10:02:32

    It doesn’t feel awkward if you use it too much. It only feels awkward if you use <% %> to insert a piece of java code

    reply
    0
  • Cancelreply