我在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错误“未终止字符串文字”,我无法找到线索,请帮忙。