el表達式的if else用法 隨便記錄下

el表達式要想使用if else 必須得用<c:choose></c:choose>標籤

比如

<c:choose>

    <c:when test="${not empty getchecknum}">

    如果getchecknum對象不爲空 如何如何

   </c:when>

   <c:otherwise>

     否則如何如何

  </c:otherwise>

</c:choose>

 

例子

<form id="searchForm" method="post">
    <div class="tab">      
           <h3>審批意見</h3>
        <p><textarea rows="" cols="" placeholder="請輸入審批意見..." id="remarks" required name="remarks" class="tab-content"></textarea></p>
    </div>
        <c:choose>
            <c:when test="${not empty getchecknum}">
                <div style="margin-bottom: 20px;">
                    <label for="operator">經辦人:</label> 
                    <input id="operator" name="operator" value="${getchecknum.operator }">
                    <label for="operatorPhone" style="margin-left: 40px;">經辦人電話:</label>
                    <input id="operatorPhone" name="operatorPhone" value="${getchecknum.operator_phone }" class="number"> 
                    <label for="operatorQq" style="margin-left: 40px;">經辦人QQ:</label>
                    <input id="operatorQq" name="operatorQq" value="${getchecknum.operator_qq }">
                </div>
            </c:when>
            <c:otherwise>
                <div style="margin-bottom: 20px;">
                    <label for="operator">經辦人:</label> <input id="operator"
                        name="operator" value="${loginUser.name }"> <label
                        for="operatorPhone" style="margin-left: 40px;">經辦人電話:</label> <input
                        id="operatorPhone" name="operatorPhone"
                        value="${loginUser.phone }"> <label
                        for="operatorQq" style="margin-left: 40px;">經辦人QQ:</label> <input
                        id="operatorQq" name="operatorQq"
                        value="">
                </div>
            </c:otherwise>
        </c:choose>
    </form>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章