How can I replace newline characters using JSP and JSTL?

前端 未结 14 1969
遥遥无期
遥遥无期 2020-12-02 22:15

I have a list of bean objects passed into my JSP page, and one of them is a comment field. This field may contain newlines, and I want to replace them with semicolons using

14条回答
  •  广开言路
    2020-12-02 23:04

    This does not work for me:

    
    ${fn:replace(data, newLine, "; ")}
    

    This does:

    <% pageContext.setAttribute("newLineChar", "\n"); %> 
    ${fn:replace(item.comments, newLineChar, "; ")}
    

提交回复
热议问题