How to escape HTML special characters in Java?

后端 未结 5 1659
名媛妹妹
名媛妹妹 2021-01-01 21:01

Is there a way to convert a string to a string that will display properly in a web document? For example, changing the string

\"\"
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 21:47

    StringEscapeUtils has functions designed exactly for this:

    http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/commons/lang3/StringEscapeUtils.html

提交回复
热议问题