后台代码
String str="dfrfdsfd";
final String vEnter = "(\r\n|\r|\n|\n\r)";
final String br = "<br/>";
str = str.replaceAll(vEnter, br);
再转换一次
document.getElementById("answer").value=document.getElementById("answer").value.replace(/<br\/>/g,'\n')
后台代码
String str="dfrfdsfd";
final String vEnter = "(\r\n|\r|\n|\n\r)";
final String br = "<br/>";
str = str.replaceAll(vEnter, br);
再转换一次
document.getElementById("answer").value=document.getElementById("answer").value.replace(/<br\/>/g,'\n')