When you add th:text to an element, it replaces the entire contents of that element -- in your case, this is overwriting the <button /> tags with the pet name. To fix this, you want to put the th:text in another tag of it's own, so that the rest of the tags aren't affected. Something like this: