java - JSP中读取字符串

标签 java jsp string

String strFCKeditor1 = request.getParameter("FCKeditor1");

我想读取此 (strFCKeditor1) 字符串,并希望将其中的 " 替换为 \"

我该怎么做?

最佳答案

尝试

strFCKeditor1 = strFCKeditor1.replace("\"", "\\\"");

这是“Java 字符串转义”方式,表示将 " 替换为 \"

参见ideone.com demo here .

来自replace的文档:

Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.

关于java - JSP中读取字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4826072/

相关文章:

Java UDP 多播 - 奇怪的异常

MySql 连接中的 Java ClassNotFoundException (java.sql.SQLType)

javascript - 如何将.js文件中的JS函数调用到.jsp文件中?

python - 单元格中的 Pandas 字符串到新行

string - Smalltalk 中子串的索引

java - 如何检索文件的修改日期?

java - Struts 2 post参数从Action A到Action B

java - Spring Boot在多模块项目中找不到jsp

java - IntelliJ 的 CSS 即时验证能做多少?

python - 如何从文件内容重新创建 float 列表列表?