我在Java中有以下字符串:
"this is text1\r\nthis is text2\r\nthis is text3"
我替换\r\n
如下<br/>
:
String temp = "this is text1\r\nthis is text2\r\nthis is text3"
temp = temp.replaceAll("[\r\n]+", "<br/>");
产生以下字符串:"is text1 this is text2 this is text3"
现在,我想将它发送到 JavaScript 元素,如下所示:
var desc_str = "<%=temp%>";
document.getElementById('proc_desc').value = desc_str;
Java 的输出很好,但是在传递给 HTML 元素后,我收到 JavaScript 错误“未终止的字符串文字”,我没有找到线索,请帮忙。