从Servlet代码修改上下文参数 [英] Modify context param from servlet code
问题描述
我知道如何获取上下文参数,但是有没有办法更改web.xml
中定义的上下文参数的值?我正在使用JSF,因此在这种情况下它将为FacesContext
.
I know how to get the context params, but is there a way to change the value of the context params defined in the web.xml
? I'm using JSF so in this case it will be FacesContext
.
推荐答案
您可以并且不应该以编程方式更改它们.这会打败他们的目的.只需直接在web.xml
中更改它们,或寻找其他解决方案-我无法建议,因为尚不清楚此需求背后的具体功能要求.我至少可以暗示JNDI可以覆盖某些特定的上下文参数,例如
You can and should not change them programmatically. It would defeat their purpose. Just change them straight in the web.xml
, or look for a different solution --which I can't suggest as the concrete functional requirement behind this need is unclear. I can at least hint that some specific context parameters are overrideable by JNDI, for example the javax.faces.PROJECT_STAGE
.
这篇关于从Servlet代码修改上下文参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!