How to deal with invalid characters in a WS output when using CXF?

前端 未结 4 1494
感动是毒
感动是毒 2021-02-07 06:00

I\'m using Spring, CXF and Hibernate to build a WebService that perform search queries on a foreign database that I have read-only access.

The problem is that some entri

4条回答
  •  暖寄归人
    2021-02-07 06:23

    /**
    * From xml spec valid chars:
    * #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
    * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
    * @param text The String to clean * @param replacement The string to be substituted for each match * @return The resulting String */ public static String CleanInvalidXmlChars(String text, String replacement) { String re = "[^\u0009\r\n\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF]"; return text.replaceAll(re, replacement); }

    source: http://www.theplancollection.com/house-plan-related-articles/hexadecimal-value-invalid-characterheplancollection.com/house-plan-related-articles/hexadecimal-value-invalid-character

提交回复
热议问题