+ -
当前位置:首页 → 问答吧 → 请问在jsp中怎么样用replace把\n替换成 <br>

请问在jsp中怎么样用replace把\n替换成 <br>

时间:2011-09-27

来源:互联网

我用的是jdk1.5版本 
我用这种方法替换cont=cont.replaceAll("\n","<br>"); 
但是在运行的时候提示错误为:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 5 in the jsp file: /Post.jsp
Generated servlet error:
String literal is not properly closed by a double-quote

作者: hjqrs   发布时间: 2011-09-27

再加个/呢

作者: li498833284   发布时间: 2011-09-27

还不好使。。。

作者: hjqrs   发布时间: 2011-09-27

JScript code
cont=cont.replace(/\n/g,"<br>")

作者: chinalian   发布时间: 2011-09-27