How can I replace newline characters using JSP and JSTL?

前端 未结 14 1961
遥遥无期
遥遥无期 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条回答
  •  旧时难觅i
    2020-12-02 22:53

    For the record, I came across this post while tackling this problem:

    A multi-line string in JSTL gets added as the title attribute of a textarea. Javascript then adds this as the default text of the textarea. In order to clear this text on focus the value needs to equal the title... but fails as many text-editors put \r\n instead of \n. So the follownig will get rid of the unwanted \r:

    <% pageContext.setAttribute("newLineChar", "\r"); %> 
    
    

提交回复
热议问题