我正在尝试在 JSF 中重写旧版应用程序,而其他已重写的应用程序已在页脚中发布了 maven 版本。
我试图弄清楚他们是如何做到的,到目前为止,这就是我发现他们正在做的事情:
页脚.xhtml
<h:outputText id="fullBuildString" value="#{ApplicationInfo.fullBuildString}" />
ApplicationInfoBacking.java
public class ApplicationInfoBacking {
private String buildTime;
private String iteration;
private String version;
private String inception;
private String fullBuildString;
@PostConstruct
public void init() {
fullBuildString = generateFullBuildString();
}
public String getBuildTime() {
return buildTime;
}
public void setBuildTime(final String buildTime) {
this.buildTime = buildTime;
}
public String getIteration() {
return iteration;
}
public void setIteration(final String iteration) {
this.iteration = iteration;
}
public String getVersion() {
return version;
}
public void setVersion(final String version) {
this.version = version;
}
public String getInception() {
return inception;
}
public void setInception(final String inception) {
this.inception = inception;
}
/**
* @return ApplicationName vVersion (Iteration) BuildTime
*/
public String getFullBuildString() {
return fullBuildString;
}
public String generateFullBuildString() {
if ((version == null) || "".equals(version.trim())) {
version = "Unknown version";
}
if ((iteration == null) || "".equals(iteration.trim())) {
iteration = "Unknown iteration";
}
if ((buildTime == null) || "".equals(buildTime.trim())) {
buildTime = "Unknown build time";
}
final StringBuilder build = new StringBuilder();
build.append("v. ").append(version);
if (!Phase.PRODUCTION.equals(PlatformUtil.getPhase()) && !Phase.BETA.equals(PlatformUtil.getPhase())) {
build.append(" (").append(iteration).append(")");
build.append(" ").append(buildTime);
}
return build.toString();
}
}
面孔-config.xml
<managed-bean>
<managed-bean-name>ApplicationInfo</managed-bean-name>
<managed-bean-class>path.to.class.ApplicationInfoBacking</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>buildTime</property-name>
<value>#{initParam.buildTime}</value>
</managed-property>
<managed-property>
<property-name>iteration</property-name>
<value>#{initParam.iteration}</value>
</managed-property>
<managed-property>
<property-name>version</property-name>
<value>#{initParam.version}</value>
</managed-property>
<managed-property>
<property-name>inception</property-name>
<value>#{initParam.inception}</value>
</managed-property>
</managed-bean>
web.xml
<context-param>
<param-name>buildTime</param-name>
<param-value>${buildNumber}</param-value>
</context-param>
<context-param>
<param-name>iteration</param-name>
<param-value>${iteration}</param-value>
</context-param>
<context-param>
<param-name>version</param-name>
<param-value>${pom.version}</param-value>
</context-param>
这是我加载应用程序时实际显示的内容:
v. ${pom.version}
由于某种原因,${pom.version}
没有得到解释。
有谁知道为什么?