2016-10-13 101 views
1

特殊字符我運行此查詢在下面的XML文件:逃避XML

<?xml version="1.0" encoding="UTF-8"?> 
    .. 
    ... 
    <query> 
     update tableX set colName='$ClassService.getParameter(\"param1\")$' where id = '0' 
    </query> 
    ... 

我收到以下錯誤:

ERROR]: Exception occurred, terminating. java.lang.IllegalArgumentException: Exception parsing or evaluating ClassService.getParameter(\"param1\")

如何逃脫「正確

+0

有沒有必要逃避'「'在XML字符,除非你在屬性中找到他們,我認爲你可以直接寫'ClassService.getParameter(」參數1 「)' – potame

+0

那麼我得到了相同的錯誤 – Ronald

+0

所以我想你的問題不在於XML轉義。你的XML被評估和使用在其他地方,並引發異常。也許你可以發送完整的堆棧跟蹤? – potame

回答

0

什麼只需要使用CDATA部分?

<![CDATA[ 
Within this Character Data block I can 
use double dashes as much as I want (along with <, &, ', and ") 
*and* %MyParamEntity; will be expanded to the text 
"Has been expanded" ... however, I can't use 
the CEND sequence (if I need to use it I must escape one of the 
brackets or the greater-than sign). 
]]> 

或者這不符合您的要求?

,使其類似於此:

<?xml version="1.0" encoding="UTF-8"?> 
.. 
... 
<query> 
    <![CDATA[ 
    update tableX set colName='$ClassService.getParameter(\"param1\")$' where id = '0' 
    ]]> 
</query> 
... 
+0

我試過它但我得到相同的錯誤:( – Ronald