Common Jstl Tags

Source: Internet
Author: User

1. Determine if it is empty

<c:choose>    <c:when test="${not empty ReportInfo.user_register_orgs.register_orgs_ Statistics}">        <tr>            <td>${reportinfo.user_register_orgs.register_orgs_ Statistics.count}</td>            <td>${reportInfo.user_register_orgs.register_orgs_statistics.label}< /TD>        </tr>    

2. Judging by conditions

<c:choose>    <c:when test="${reportinfo.user_gray.has_report = = ' 1 '}">         Yes     </c:when>    <c:otherwise>         no     </c:otherwise></c: Choose>

3. JSON loop

<c:choose> <c:when test="${not Empty ReportInfo.user_idcard_suspicion.idcard_with_other_phones}"> <c:foreach items="${reportinfo.user_idcard_suspicion.idcard_with_other_phones}" var="Ruisiwop"varstatus="vs"> <tbody> <trclass="TC"> <td>${ruisiwop.susp_phone}</td> <td>${ruisiwop.susp_phone_ope                    Rator}</td> <td>${ruisiwop.susp_phone_province}/${ruisiwop.susp_phone_city}</td> <td>${ruisiwop.susp_updt}</td> </tr> </tbody> < /c:foreach> </c:when></c:choose>

4. Percentage of digital display

<fmt:formatnumber type="percent" value="${reportinfo.user_ Gray.contacts_number_statistic.pct_cnt_to_black}" />

5. Date formatting


(1) Date format output in the JSTL tag

Use the JSTL tag in a JSP page to convert a long timestamp to a formatted time string

1. Import Java.util.Date class via <jsp:usebean/>
2. Set the long time property value for a date instance by <jsp:setproperty/>
3. Format a date instance by <fmt:formatdate/>

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"prefix="FMT"%><jsp:usebean id="DateValue" class="java.util.Date"/><jsp:setproperty name="DateValue"property=" Time"Value="${timestampvalue}"/><fmt:formatdate value="${datevalue}"pattern="mm/dd/yyyy hh:mm"/>

(2) JSTL formatting timestamps, such as 1427264998586 how to display 2015-03-25 02:29:58 such a format? Let's look at the following code:

<jsp:usebean id="mydate" class="java.util.Date"/> <c:Settarget="${mydate}"property=" Time"Value="${obj.date}"/> <fmt:formatdate pattern="YYYY-MM-DD Hh:mm:ss"Value="${mydate}"Type="both"/>

The package needs to be imported:

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt  " %>

Common Jstl Tags

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.