问题
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