• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to put java.util.List in text area with line breaks?  RSS feed

 
Matt Taylor
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
List list = new ArrayList<String>();
list.add("1");
list.add("2");


I want to put the list in the textarea with this format:
1
2

What happens is the output in text area is:
[1,2]


this is my code in jsp:

<textarea id="list" class="form-control" rows="3" value="${list}"></textarea>
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is because ${list} in EL calls the toString() method of the list object.
You can check the code of AbstractCollection.toString().
So now have you got some idea how to achieve the desired output?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!