如何在<env-entry-value>中将xml数据作为值

时间:2015-08-31 18:22:31

标签: java xml

我想在我的环境变量中使用Xml数据,如下所示:

    <env-entry>
        <description>xmLData</description>
        <env-entry-name>xml/data</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value><myXmlData><myRequest><TransactionID xmlns=\"\"></env-entry-value>
    </env-entry>  

但是我得到了如下的complilation错误:

The element type "env-entry-value" must be terminated by the matching end-tag "</env-entry-value>"  

以前这是使用属性文件完成的,但现在无法再使用属性文件了 关于如何将xml数据作为自定义Jndi变量发送的任何建议?

PS:我使用的是Websphere 8.5,Java和struts 1.2。

1 个答案:

答案 0 :(得分:0)

您需要转义XML特殊字符:

<env-entry-value>&lt;myXmlData>&lt;myRequest>&lt;TransactionID xmlns="">...</env-entry-value>

...或者使用CDATA部分转义整个XML块:

<env-entry-value><![CDATA[<myXmlData><myRequest><TransactionID xmlns="">...]]></env-entry-value>