how keep textarea line break

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

how keep textarea line break

ysykzheng
java code:

PostEditForm postForm2 = new PostEditForm();
    postForm2.setContent("abc\ndef\nhello world");
    model.addAttribute("postForm2", postForm2);

html template:

<form id="postForm2"  method="POST" th:object="${postForm2}"
              enctype="multipart/form-data">

          <div class="form-group">
          <textarea
              class="form-control" name="content2" id="content2"
              th:field="*{content}"
              rows="10" cols="40" maxlength="5000"
          >
          </textarea>
          </div>
        </form>

the html result:

<textarea
              class="form-control" name="content" id="content2"
              rows="10" cols="40" maxlength="5000"
          >abc def hello world</textarea>

I want get result like this:

<textarea
              class="form-control" name="content" id="content2"
              rows="10" cols="40" maxlength="5000"
          >abc
def
hello world</textarea>