有没有人有使用循环的任何简单JEXL示例.我想遍历一个简单的数组以输出各种字符串值? [英] Does anyone have any simple JEXL examples using a loop. I am looking to iterate around a simple Array to output various string values?
本文介绍了有没有人有使用循环的任何简单JEXL示例.我想遍历一个简单的数组以输出各种字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人有没有使用循环的简单JEXL示例.我想遍历一个简单的对象arraylist来输出各种字符串值?
Does anyone have any simple JEXL examples using a loop. I am looking to iterate around a simple object arraylist to output various string values?
推荐答案
此处输入452'的完整示例:
A full example with input for 452' is here :
public static void testSimpleList() {
List<String> list = new ArrayList<String>();
list.add("one");
list.add("two");
JexlContext jexlContext = new MapContext();
jexlContext.set("list", list);;
Map<String, Object> functions1 = new HashMap<String, Object>();
functions1.put("system", System.out);
JexlEngine jexl = new JexlEngine();
jexl.setFunctions(functions1);
Expression expression = jexl.createExpression("for(item : list) { system:println(item) }");
expression.evaluate(jexlContext);
}
输出:
one
two
这篇关于有没有人有使用循环的任何简单JEXL示例.我想遍历一个简单的数组以输出各种字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文