Вопрос

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