在 JSF 中显示服务器启动时间

Display server starting time in JSF

OmniFaces showcase site 页脚所示(滚动到页面底部)。

Server (re)started at 12 Jun 2015 08:50 UTC

如何显示最后一个服务器的时间 restart/start or/and quellcode 的最后更新,如果可能的话。

OmniFaces 展示也是 open source. You can find the responsible code in line 100 of /WEB-INF/templates/layout.xhtml

<p>Server (re)started at #{of:formatDateWithTimezone(startup, 'd MMM yyyy HH:mm', 'UTC')} UTC</p>

因此使用 OmniFaces 自己的 #{startup} managed bean for this which is basically registered as below in OmniFaces own faces-config.xml:

<managed-bean eager="true">
    <managed-bean-name>startup</managed-bean-name>
    <managed-bean-class>java.util.Date</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
</managed-bean>

在"plain JSF"中你可以显示如下:

<h:outputText value="#{startup}">
    <f:convertDateTime pattern="d MMM yyyy HH:mm" />
</h:outputText>