Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thymeleaf #strings.trim() doesn't work

In short: I'm getting data from google places api and want to create entity in my db based on it. I have @Email annotation on a username field, so it can't contain white spaces. I was trying to use something like this:

th:value="${#strings.trim(place.name) + '@mywebsite.com'}"

But, it seems not work... I also tried different methods, just to double check if syntax is correct, on #strings like:

th:value="${#strings.toLowerCase(place.name) + '@mywebsite.com'}"

and its works just fine.

Thanks in advance!

like image 843
Nick Nagorski Avatar asked Nov 20 '25 04:11

Nick Nagorski


1 Answers

I'm assuming by the latest comments that you want to replace white spaces, something like:

this is an email to thisisanemail

You can try:

th:value="${#strings.replace(place.name,' ','') + '@mywebsite.com'}" 

The above code is an example of how to do it in thymeleaf but, in my opinion, you should handle it in the backend.

like image 161
juanlumn Avatar answered Nov 22 '25 17:11

juanlumn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!