Escaping javascript string in java

前端 未结 3 2036
失恋的感觉
失恋的感觉 2020-12-03 21:23

I need to make this into a string in java:

 

        
相关标签:
3条回答
  • 2020-12-03 21:55

    Looks like it was moved in Apache Commons Lang 3 to ESCAPE_ECMASCRIPT in StringEscapeUtils.

    https://commons.apache.org/proper/commons-lang/javadocs/api-3.4/src-html/org/apache/commons/lang3/StringEscapeUtils.html#line.74

    0 讨论(0)
  • 2020-12-03 22:05

    It seems it moved yet again, now it is part of "commons-text" and is named:

    StringEscapeUtils.escapeEcmaScript
    

    But good it still exists.

    0 讨论(0)
  • 2020-12-03 22:06

    Apache commons have a methods just for this in StringEscapeUtils : the escapeJavaScript method.

    0 讨论(0)
提交回复
热议问题