我的webapp会抛出此错误:
weblogic.servlet.jsp.CompilationException: Failed to compile JSP /pages/workbench/user/taskassessmentexample.jsp
taskassessmentexample.jsp:204:230: Invalid character constant
String message = "<b>" + riskNote.getUser() + "</b> (<span style=\"font-size:80%\">" + riskNote.getDisplayTimeStamp() + "</span> ) : <span style=\"font-style:italic;\">" + riskNote.getMessage().replaceAll('\n','<br/>') + "</span><br/>";
^----^
at weblogic.servlet.jsp.JavelinxJSPStub.reportCompilationErrorIfNeccessary(JavelinxJSPStub.java:226)
生成它的JSP是:
String message = "<b>" + riskNote.getUser() + "</b> (<span style=\"font-size:80%\">" + riskNote.getDisplayTimeStamp() + "</span> ) : <span style=\"font-style:italic;\">" + riskNote.getMessage().replaceAll('\n','<br/>') + "</span><br/>";
out.println(message);
我错过了一些非常明显的东西吗?
答案 0 :(得分:6)
您应该在以下位置看到编译错误:
... replaceAll('\n','<br/>') ...
因为这些参数应该是用双引号括起来的字符串:
... replaceAll("\n", "<br/>") ...