Thymeleaf + Spring : How to keep line break?
I'm using Thymeleaf template engine with spring and I'd like to display text stored throught a multiline textarea. In my database multiline string are store with "\n" like this : "Test1\nTest2\n...." With th:text i've got : "Test1 Test2" with no line break. How I can display line break using Thymeleaf and avoid manually "\n" replacing with < br/> and then avoid using th:utext (this open form to xss injection) ? Thanks ! Two of your options: Use th:utext - easy setup option, but harder to read and remember Create a custom processor and dialect - more involved setup, but easier, more readable