如何通过Tomcat中的JNDI配置JSF 2.0应用程序的项目阶段 [英] How to configure JSF 2.0 application's project stage via JNDI in Tomcat

查看:114
本文介绍了如何通过Tomcat中的JNDI配置JSF 2.0应用程序的项目阶段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

努力寻找一种方法来配置Tomcat 7.0.11,以便我的Web应用程序将使用Tomcat的配置中的项目阶段设置.到目前为止-没有运气.这个想法是在Tomcat服务器/主机/应用程序范围内设置此属性,而不是在web.xml中设置它.有任何想法吗?我正在使用MyFaces JSF 2实现2.0.5.

been struggling to find a way to configure Tomcat 7.0.11 so that my web application would use project stage setting from Tomcat's config. So far - no luck. The idea is to set this property in Tomcat server/host/application wide but not to set it in web.xml. Any ideas? I am using MyFaces JSF 2 implementation 2.0.5.

推荐答案

该规范说JSF实现在 java:comp/env/jsf/ProjectStage 下使用JNDI查找项目阶段.如果未找到,它将使用web.xml中的上下文参数javax.faces.PROJECT_STAGE.这意味着,如果使用JNDI在Tomcat上定义/找到了该值,则首选值将超过web.xml设置.

The specification says that the JSF implementation looks up the Project Stage using JNDI under java:comp/env/jsf/ProjectStage. If not found it uses the context parameter javax.faces.PROJECT_STAGE from your web.xml. This means that if defined/found on your Tomcat using JNDI, the value of preferred over the web.xml setting.

您可以做两件事:

选项1::覆盖上下文参数:这意味着可以使用Tomcat server.xml或context.xml设置/覆盖上下文参数.您需要将其放入您的< Context> -tag:

Option 1: Overwrite the context parameter: This means that context parameter is set/overwritten using the Tomcat server.xml or context.xml. You need to put this in your <Context>-tag:

<Parameter name="javax.faces.PROJECT_STAGE" value="Production" override="false" />

小心: override ="false" 这里表示该参数不能被web.xml覆盖(反之亦然)!

Careful: override="false" here means that this parameter can NOT be overriden by the web.xml (not the other way around)!

选项2:配置可以使用JNDI找到的资源:通过这种方式,JSF实施可以使用JNDI查找来解决项目阶段.

Option 2: Configure a resource that can be found using JNDI: By using this that JSF implementation can resolve the project stage using the JNDI lookup.

<Environment name="jsf/ProjectStage" value="Production" type="java.lang.String" override="false"/>

您也可以将其移到server.xml中的< GlobalResources>标记中.在这种情况下,您需要使用< ResourceLink>-标签在< Context>标签中进行引用.

You can also move this to the <GlobalResources>-tag in your server.xml. In this case you would need to reference this in your <Context>-tag by using <ResourceLink>-tag.

这篇关于如何通过Tomcat中的JNDI配置JSF 2.0应用程序的项目阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆