【问题标题】:How to send illegal XML elements in the body of a http request?如何在 http 请求的正文中发送非法 XML 元素?
【发布时间】:2014-09-02 14:33:55
【问题描述】:

我正在以xml 格式进行POST 和发布数据,但我想传递<>@ 等值。

<test name="test">#,#,<</test>

&lt;&gt; 字符有问题。有没有办法传递这些值?我无法更改输入格式。

【问题讨论】:

  • 你能对 XML 进行 URLEncode 吗?
  • 然后我将对所有发布数据进行编码。我猜你的意思是为 XML 编码?
  • 在您的 POST 管理中,您只需 URLDecode 即可。只需确保使用 form/urlencoded 作为内容类型并将 xml 作为 POST 参数发送(例如 xmlData=URLEncode.encode(yourXmlString); )
  • 你可以使用commons-lang中的StringEscapeUtils:commons.apache.org/proper/commons-lang/javadocs/api-release/org/…
  • 我决定以编码格式发帖。

标签: java parsing post sax


【解决方案1】:

使用CDATA 包装XML 内容。

<![CDATA[
    XML  content
]]>

【讨论】:

    猜你喜欢
    • 2020-02-12
    • 2016-10-21
    • 2014-03-12
    • 1970-01-01
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-12
    相关资源
    最近更新 更多