使用JSTL formatDate标记显示当前日期 [英] Showing the current date using JSTL formatDate tag

查看:208
本文介绍了使用JSTL formatDate标记显示当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JSTL在JSP页面中显示当前日期。以下是我正在使用的代码。

I am trying to show the current date in my JSP page using JSTL. below is the code I am using.

<jsp:useBean id="now" class="java.util.Date" scope="request" />
<fmt:formatDate value="${now}" pattern="MM.dd.yyyy" />

但上面的代码没有产生任何结果?我在这里遗漏了什么,还是有更好的方法呢?我正在使用JSTL 1.1。

But the above code is not producing any results? Am I missing anything here or is there any better approach for this? I am using JSTL 1.1.

推荐答案

尝试打印没有格式化,$ {now},你可能有 null 在那里。请求范围内有这个属性吗?只要双重检查,如果是,可能是 null 。如果没有,请尝试从标签中删除此范围属性,是的,这并不重要,只是为了使事情清晰。

Try to print it without formatting, ${now}, you probably have null in there. Do you have this attribute in request scope? Just double check, if yes it might be null. If not, then try remove this scope attribute from the tag, yeah it doesn't matter but just to make the things clear.

这篇关于使用JSTL formatDate标记显示当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆