문제

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