当前位置: 代码迷 >> Java Web开发 >> 请教在jsp中如何样用replace把\n替换成 <br>
  详细解决方案

请教在jsp中如何样用replace把\n替换成 <br>

热度:293   发布时间:2016-04-17 01:06:26.0
请问在jsp中怎么样用replace把\n替换成 <br>
我用的是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

------解决方案--------------------
再加个/呢
------解决方案--------------------
JScript code
cont=cont.replace(/\n/g,"<br>")
------解决方案--------------------
\n这个不对
------解决方案--------------------
探讨
JScript code
cont=cont.replace(/\n/g,"<br>")

代码迷推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.daimami.com/search?q=2308
  相关解决方案