0

I have this piece of code in my Thymeleaf template

<td class="col_name" th:text="${carPriceSummary.price} + &nbsp;&euro; "></td>

But I got this error:

Could not parse as expression: "${carPriceSummary.price} +  € "

2 Answers 2

1

Welcome to SO.

You may be better off using the utility method for currency that would include the appropriate symbol based on the locale:

<td class="col_name" th:text="${#numbers.formatCurrency(carPriceSummary.price)}">[price]</td>

but otherwise, adding the string representation would be a hacky way to do it:

<td class="col_name" th:text="${carPriceSummary.price} + ' &euro;' ">[price]</td>

In either case, I would recommend including a default string like [price] so that it can be opened directly in a browser with the col_name class applied. This is a key strength to using Thymeleaf.

Sign up to request clarification or add additional context in comments.

Comments

1

That's because &nbsp;&euro; is not a valid expression. You'd at least need to make sure it's recognised as a string, ie put it in quotes.

I recommend the literal substitution format

th:text="|${carPriceSummary.price}&nbsp;&euro; |"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.