如何使用JSTL在JSP中捕获变量中的当前日期和时间?

 狗狗水灵灵_266 发布于 2023-02-08 10:59

如何使用JSTL在JSP中捕获变量中的当前日期和时间?

 

我在我的JSP中使用上面的代码但它抛出了一个错误.

org.apache.jasper.JasperException: The function currentTimeMillis must be used with a prefix when default namespace is not specified.

Pirabu Govin.. 8

巴鲁,试试这个......










更新代码..




Start date time is in the past.


Start date time is in the future.


Start date time is identical to now.

巴鲁尝试这一个..

1 个回答
  • 巴鲁,试试这个......

    <jsp:useBean id="now" class="java.util.Date" />
    
    <fmt:formatDate type="time" value="${now}" /><br/>
    <fmt:formatDate type="date" value="${now}" /><br/>
    <fmt:formatDate type="both" value="${now}" /><br/>
    <fmt:formatDate type="both" date time
        value="${now}" /><br/>
    <fmt:formatDate type="both" date time
        value="${now}" /><br/>
    <fmt:formatDate type="both" date time
        value="${now}" /><br/>
    <fmt:formatDate pattern="yyyy-MM-dd" value="${now}" /><br/>
    

    更新代码..

    <jsp:useBean id="now" class="java.util.Date" />
    <jsp:useBean id="bean" class="demo.Sample" />
    <c:if test="${bean.timestamp lt now}">
    Start date time is in the past.
    </c:if>
    <c:if test="${bean.timestamp gt now}">
    Start date time is in the future.
    </c:if>
    <c:if test="${bean.timestamp eq now}">
    Start date time is identical to now.
    </c:if>
    

    巴鲁尝试这一个..

    2023-02-08 11:02 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有