Re: Thymeleaf 2.1.3 JUST PUBLISHED

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf 2.1.3 JUST PUBLISHED

niels
Great. Unfortunately I get trouble if I wrote

<div th:object="${project}">
     <span th:text="*{{manager}}"></span>
</div>

I get
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type @javax.persistence.ManyToOne de.ppi.promato.persistence.model.all.User to type java.lang.String
	at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:276)
	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:171)
	at org.springframework.expression.spel.support.StandardTypeConverter.convertValue(StandardTypeConverter.java:72)

so it looks that now there is no ToStringConverter registered in this case, which is normally part of the defaultconverter.

How ever I think it's better to write converter than toString()-methods. Main problem is to repair the current version. Any suggestions?

Regards
Niels
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf 2.1.3 JUST PUBLISHED

danielfernandez
Administrator
(Moved post to "General usage")

Nothing has changed in 2.1.3 in relation to how the ConversionService components are managed (they are managed by Spring, in fact). What has changed is how Thymeleaf calls the SpringEL engine, which is what makes Spring itself apply the ConversionService instead of Thymeleaf having to do it manually.

But if this worked with 2.1.2 for you and not with 2.1.3, it can be because you never actually had a Spring converter for User -> String, and Thymeleaf 2.1.2 was detecting this before calling the ConversionService manually, and therefore defaulting to just calling "toString()" on your User object. So it was Thymeleaf, not Spring, who was converting your object to String in 2.1.2.

In 2.1.3 there is simply no possibility to do this: all the conversion control is handed over to Spring, and failing when no suitable converter is found seems to be the Spring default behaviour. So my suggestion would be to add such suitable converter to your Spring configuration...

By the way, if you don't have a User -> String converter, then you don't need that "*{{manager}}" at all. You can simply use "*{manager}" and Thymeleaf will execute "User.toString()" for you.

Regards,
Daniel.