简体   繁体   English

推土机定制转换器适用于所有领域

[英]Dozer custom converter applies on all fields

I just declared the following converter 我刚刚声明了以下转换器

<converter type="co.mine.converter.ProductToNameConverter">
          <class-a>java.lang.String</class-a>
          <class-b>java.lang.String</class-b>
</converter>

and in the mapping file: 并在映射文件中:

<field custom-converter="co.mine.converter.ProductToNameConverter">
        <a>productId</a>
        <b>product</b>
</field>

but for every mapping field, where source is String and destination is String also, this converter has been called. 但是对于每个映射字段,其中source是String ,destination也是String ,已经调用了此转换器。 So how should I avoid such behavior? 那么我应该如何避免这种行为呢? In other words, I only want that converter to work on productId and product . 换句话说,我只希望该转换器对productIdproduct起作用。

If you want the converter to work only for productId and product your second configuration is enough. 如果您希望转换器仅对productIdproduct工作,则第二个配置就足够了。 Remove the first. 删除第一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM