gpt4 book ai didi

java - 转义xml中的特殊字符

转载 作者:太空宇宙 更新时间:2023-11-04 12:09:21 24 4
gpt4 key购买 nike

我在以下 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\")

如何正确转义“?

最佳答案

是否只使用 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>
...

关于java - 转义xml中的特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40017087/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com