0

我有一些文本,我想使用 java(在 jsp 页面上)和使用 javacript 显示。但是当我使用 \ 时,javascript 中的文本会正确显示,但 java 会用一个反斜杠显示它。文字是一样的,有什么方法可以让它们以相同的方式显示吗?

4

1 回答 1

0

出于各种安全原因,这就是所谓的“转义序列”,许多字符在直接写入字符串文字时不会打印。

常见的 c 样式转义序列以 '\' (反斜杠字符)为前缀,后跟要转义的字符

'\\' 是您要打印单个 '\' 字符的字符序列。

维基页面

请参阅旧的 stackoverflow评论

 - \t Insert a tab in the text at this point.
 - \b Insert a backspace in the text at this point.
 - \n Insert a newline in the text at this point.
 - \r Insert a carriage return in the text at this point.
 - \f Insert a formfeed in the text at this point.
 - \' Insert a single quote character in the text at this point.
 - \" Insert a double quote character in the text at this point.
 - \\ Insert a backslash character in the text at this point.
于 2014-02-04T08:27:52.070 回答