Formatter和IStandardConversionService的使用方式

Thymeleaf

1.Formatter接口是当进行请求参数的封装时,会根据Formatter的泛型进行调用Parse方法进行格式化类型

2.IStandardConversionService是Thymeleaf的一个接口,进行数据转换或格式化的操作,使用需要通过${{}}或*{{}}进行使用,需要在视图文件上进行使用

 

 

Thymeleaf转换服务的实用对象#conversions.convert是通过convertOther方法进行转换到指定类型的,而convertString方法是通过${{}}或*{{}}进行调用的

 

Thymeleaf+Spring

Thymeleaf双括号语法经测试,使用FormatterRegistry进行注册Formatter Bean之后,在Thymeleaf视图层使用${{}},则根据值的类型,调用相应泛型的Formatter的Print方法,否则无法将XXX类型转换为String将抛出 No converter found capable of converting from type XXX to type [java.lang.String]

posted @ 2019-08-31 22:35  星小梦  阅读(275)  评论(0编辑  收藏  举报