问题
I have a JSP page which includes a button called "Download".I want to hide this button based on a if-condition.
The Download button is meant to generate and download PDF onclick of it.
I have a List that is being fetched from the Controller and if this list is empty, I want to hide the "Download" button on the JSP page.
This is my button,
<button type="button" class="btn bg-red waves-effect" onclick="ExportPdf()">Download</button>
I want to hide the button if the List is empty.
回答1:
Display when list isn't empty:
<% if (!list.isEmpty()){ %>
<button type="button" class="btn bg-red waves-effect" onclick="ExportPdf()">Download</button>
<% } %>
For example if you fetch list from attribute
ArrayList<String> list = (ArrayList<String>) request.getAttribute("listName");
来源:https://stackoverflow.com/questions/56236527/hide-a-html-button-based-on-a-if-condition