在tomcat服务器上,我需要通过jndi为spring应用程序读取 Context.xml / Server.xml / Web.xml 中的值来填充单例字符串列表。我发现没有标签携带列表参数而不是环境/资源/参数。
我找到了解决方法
<context-param>
<param-name>SystemVariables</param-name>
<param-value>ex1.com,ex2.com,ex3.com</param-value>
</context-param>
在选择值之后,我必须将其拆分,然后填充列表。
但之前我们使用树脂,我们把jndi放在下面
<resource jndi-name="SystemVariables">
<type>com.example.SystemVariables</type>
<init>
<VarDescList>ex1.com</VarDescList>
<VarDescList>ex2.com</VarDescList>
<VarDescList>ex3.com</VarDescList>
</init>
</resource>
我们如何让它在tomcat上运行?
答案 0 :(得分:0)
你是对的,无法定义条目列表。但是在context.xml中,您可以定义“ResourceLink”并创建自己的工厂,该工厂将解析文件并返回您需要的任何内容。
工厂代码非常简单,因此创建一些代码而不是花费数小时在谷歌搜索答案可能更有价值;)
答案 1 :(得分:0)
我遇到了类似的问题。我更喜欢用逗号分隔一个并创建工厂类来拆分元素。按照我的要求解决这个问题 -
<Resource name="SystemVariables"
type="com.example.SystemVariables"
factory="com.example.SystemVariablesFactory"
VarDescList="ex1.com,ex2.com,ex3.com"/>