How can I replace newline characters using JSP and JSTL?

前端 未结 14 1959
遥遥无期
遥遥无期 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 22:57

    This is similar to the accepted answer (because it is using Java to represent the newline rather than EL) but here the element is used to set the attribute:

    " />
    ${fn:replace(myAddress, newline, "
    ")}

    The following snippet also works, but the second line of the element cannot be indented (and may look uglier):

        
        ${fn:replace(myAddress, newline, "
    ")}

提交回复
热议问题