Showing the current date using JSTL formatDate tag

十年热恋 提交于 2019-12-30 16:28:32

问题


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" />

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.


回答1:


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.




回答2:


scope=page works for me



来源:https://stackoverflow.com/questions/427726/showing-the-current-date-using-jstl-formatdate-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!