问题
I'm trying to set the project stage for JavaServer Faces in a GlassFish application server v3 with a JNDI property.
I set the stage property to Development stage, but my application received always the Production stage.

I use GlassFish Server Open Source Edition 3.1 (build 43) on a windows system.
For rendering the project stage in the JSF page I use this:
<h:outputText value="Stage:#{facesContext.application.projectStage}"/>
Is anything else necessary to use the project stage in an application? The application has no web.xml file.
回答1:
Everything is correct, but instead of stage=Development
, use value = Development
,
i.e. replace stage
with value
in the property name field.
回答2:
You need this in your web.xml. It works with 'stage' then.
<resource-ref>
<res-ref-name>jsf/ProjectStage</res-ref-name>
<res-type>java.lang.String</res-type>
<mapped-name>javax.faces.PROJECT_STAGE</mapped-name>
</resource-ref>
This maps the global JNDI property of GF to the reference lookup in JSF.
来源:https://stackoverflow.com/questions/8491904/set-project-stage-for-javaserver-faces-with-jndi-configuration-lookup-in-glassfi