Skip to content

Instantly share code, notes, and snippets.

@romach
Created April 22, 2017 14:25
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save romach/10081ba3e24ffc9f75aadada7df80df8 to your computer and use it in GitHub Desktop.
Save romach/10081ba3e24ffc9f75aadada7df80df8 to your computer and use it in GitHub Desktop.
Concatenate strings in Thymeleaf
<p th:text="${bean.field + '!' + bean.field}">Static content</p>
th:text="'static part' + ${bean.field}"
th:text="${'static part' + bean.field}"
@newddobi
Copy link

newddobi commented Dec 4, 2019

thanks, you save my time

@marcian-dao
Copy link

th:text="|First Name: ${customer.firstName} Last Name: ${customer.lastName} E-mail: ${customer.email}|"

@marcian-dao
Copy link

This is the way I do it.

@DonHamzovic
Copy link

Thanks

@manolete433
Copy link

th:text="|First Name: ${customer.firstName} Last Name: ${customer.lastName} E-mail: ${customer.email}|"

@marcian-dao , that approach worked for me. Thanks!

@marcian-dao
Copy link

Glad to be of help :)

@kaustav1810
Copy link

Thanks @marcian-dao the exact snippet I was looking for!!:)

@CharlesWilkenson
Copy link

Thank you very much

@sudarsang
Copy link

Love this, all what most blogs talk about is using th:inline which is annoying way compared to easy + '' + approach you have given here. Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment