问题
How do i escape double quotes in string in Grails :
string = " "12.10 On-Going Submission of ""Made Up"" Samples." "
I have tried alot of methods
//text : artifact.text.encodeAsJavaScript(),
//text: artifact.text.encodeAsHTML(),
//text: StringEscapeUtils.escapeJava((String)artifact.text), //got an error when doing this
//text: artifact.text.replaceAll("\" "," \\\\" "),
None of the above worked for me. You can refer to question posted by for understanding myproblem here and here too
the error (json stops at "\\"12.10 On-Going Submission o\\"\\""):
014-09-25 12:15:21,869 [http-bio-8080-exec-3] ERROR errors.GrailsExceptionResolver - StringIndexOutOfBoundsException occurred when processing request: [GET] /artifact - parameters:
documentName: ICENSE AGREEMENT6
String index out of range: -28. Stacktrace follows:
Message: String index out of range: -28
Line | Method
->> 1911 | substring in java.lang.String
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1946 | subSequence in ''
| 1042 | append . . . . in java.io.PrintWriter
| 56 | append in ''
| 180 | value . . . . in grails.converters.JSON
| 162 | convertAnother in ''
| 202 | value . . . . in ''
| 162 | convertAnother in ''
| 202 | value . . . . in ''
| 162 | convertAnother in ''
| 202 | value . . . . in ''
| 162 | convertAnother in ''
| 202 | value . . . . in ''
| 162 | convertAnother in ''
| 202 | value . . . . in ''
| 134 | render in ''
| 150 | render . . . . in ''
| 325 | $tt__index in com.thomsonreuters.ald.aeandsdx.ArtifactController$$EOqtIczI
| 198 | doFilter . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . in java.lang.Thread
来源:https://stackoverflow.com/questions/26041797/escaping-double-quotes-in-string