在String中转义双引号

时间:2014-09-25 14:58:58

标签: java grails escaping html-escape-characters

如何在Grails中以字符串形式转义双引号:

string  = " "12.10 On-Going Submission of ""Made Up"" Samples." "

我尝试了很多方法

//text : artifact.text.encodeAsJavaScript(),
//text: artifact.text.encodeAsHTML(),           
//text: StringEscapeUtils.escapeJava((String)artifact.text), //got an error when doing this     
//text: artifact.text.replaceAll("\" "," \\\\" "),

以上都不适合我。您可以参考发布的问题来了解myproblem herehere

错误(json停在“\\”12.10正在进行提交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

0 个答案:

没有答案