Display server starting time in JSF

北城余情 提交于 2019-12-13 00:43:57

问题


As seen on footer of the OmniFaces showcase site (scroll to very bottom of page).

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

How can I display the time of the last server restart/start or/and the last update of the quellcode, if it is possible.


回答1:


The OmniFaces showcase is also 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>

It's thus using OmniFaces own #{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>

In "plain JSF" you could show it as below:

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


来源:https://stackoverflow.com/questions/31427413/display-server-starting-time-in-jsf

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