This is probably some dinky little problem, but I am trying to split a string in my JSP usingn a line break. Here is the command I'm trying to use.

<c:set var="comment" value="${bulletin.note}" />
<c:set var="comment" value="${fn:split(comment, '\\n', '<br />')" />

This is the error message I'm getting. I've edited so you don't have to scroll to the right to see the whole thing, but this is the entire text of the error message.

HTTP Status 500 - /WEB-INF/jsp/BulletinApproval.jsp (line: 33, column: 3)
"${comment, '\n', '<br />')" contains invalid expression(s):
javax.el.ELException: Failed to parse the expression [${comment, '\n', '<br />')]
有帮助吗?

解决方案

You have to escape the \ twice:

<c:set var="comment" value="${fn:split(comment, '\\\\n')}" />

By the way, fn:split has only two parameters.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top