OGNL - Object Graph Navigation Library

1 优点

  • 比BeanUtils有更多的操作属性的能力,比如操作List[index]属性

2 实践

  • 引入jar包
        
            ognl
            ognl
            3.2
        
  • get & set
        HashMap map = new HashMap();
        List list= new ArrayList();
        list.add("a");      
        list.add("b");
        list.add("c");
        map.put("list", list);
        // getValue, p1 => ognl expression, p2 => root element, r => b
        Object r = Ognl.getValue("list[1]", map);
        // setValue, , p1 => ognl expression, p2 => root element, p3=> new value
        Ognl.setValue("list[1]", map, "aaa");

你可能感兴趣的:(OGNL - Object Graph Navigation Library)