在我的 Java Web 应用程序中,NTLM 域 Controller 名称在 web.xml 中指定,如下所示:
<filter>
<!-- other code -->
<init-param>
<param-name>jcifs.http.domainController</param-name>
<param-value>DCNAME</param-value>
</init-param>
<!-- other code -->
</filter>
在上面的 XML 中,我们在 param-value 标记中硬编码了域 Controller 名称 (DCNAME)。
现在,是否可以从 JNDI 变量读取此“DCNAME”,而不是将其硬编码到 web.xml 文件中?
提前致谢。
最佳答案
查看此link 。您需要像这样定义一个环境资源:
<Environment name="myName" value="whatever"
type="java.lang.String" override="false"/>
然后从代码中读取它:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
String myName = (String) envCtx .lookup("myName");
关于java - 如何从 JNDI 变量初始化 web.xml 中的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/514777/