質問

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