2017-06-15 63 views
0

我只想顯示JSP錯誤消息。這意味着如果誤差變量存在,則將會顯示其消息和形式將被隱藏。如何測試JSP中,如果條件?

<c:choose> 
    <c:when test="${errorMessage ne null}"> 
      error; ${errorMessage} //I have the error 
     </c:when> 

     <c:otherwise> 
<form action="send-mail" method="post"> 
     <table> 
      <tr> 

       <td colspan="2"><input type="text" name="email"> </td> 
      </tr> 

      <tr> 
       <td><input type="Submit" value="Reset Password"> </td> 
       <td><input type="reset" value="Cancel"> </td> 
      </tr> 

     </table> 
    </form> 
     </c:otherwise> 
</c:choose> 

謝謝你幫助我;

+0

什麼是你的問題?什麼不是工作/工作不同於你的期望? –

+0

如果'的errorMessage! =空',我想在我的HTML頁面上只有錯誤消息。因此,**表單不再出現在頁面** – Michael1

+1

請嘗試像這樣,

回答

0

問題是解決了,就必須更換:

<c:when test="${errorMessage ne null}"> 

通過

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