public interface IStandardConversionService
Common interface for all implementations of a conversion service, to be used during template execution.
Thymeleaf conversion services work in a way similar to Spring Framework's ConversionService interface, but this is a generic mechanism (not dependent on Spring).
Default implementation —registered by
StandardConversionService, which performs some standard conversions, but the
Spring Standard Dialect used by the Thymeleaf + Spring integration module automatically registers an implementation
of this interface that delegates on any existing Spring ConversionService objects (thus using
the Converters and Formatters registered at the Spring Application Context).
Important: there is one conversion that implementations of this interface should always implement, because it is heavily used at the Thymeleaf core: conversion of any Object to String.
The implementation of this interface that should be used is specified as an execution attribute
by the Standard Dialects (see
Implementations of this interface should be thread-safe.
<T> T convert(IExpressionContext context, Object object, Class<T> targetClass)
Convert a value to the specified target class, if possible.
Might raise an exception (usually
IllegalArgumentException) if a conversion is not available
for the specified object and the target class.
T- the type of the target class
context- the context object.
object- the object to be converted.
targetClass- the target class the object should be converted to.
Copyright © 2016 The THYMELEAF team. All rights reserved.