AttributesMapper(二):返回Person对象

xiaoxiao2021-02-28  52

返回Person对象的AttributesMapper Person对象与Attributes转换类:   private class PersonAttributesMapper implements AttributesMapper<Person> {      public Person mapFromAttributes(Attributes attrs) throws NamingException {         Person person = new Person();         person.setFullName((String)attrs.get("cn").get());         person.setLastName((String)attrs.get("sn").get());         person.setDescription((String)attrs.get("description").get());         return person;     }   } 使用方式:   ldapTemplate.search(query().where("objectclass").is("person"), new PersonAttributesMapper());
转载请注明原文地址: https://www.6miu.com/read-2620334.html

最新回复(0)