|
@@ -14,7 +14,9 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -60,13 +62,16 @@ public class StartTest {
|
|
Map<String,Object> map =new HashMap<>();
|
|
Map<String,Object> map =new HashMap<>();
|
|
map.put("key","1");
|
|
map.put("key","1");
|
|
Map<String,Object> map2 =new HashMap<>();
|
|
Map<String,Object> map2 =new HashMap<>();
|
|
|
|
+ List<String> list =new ArrayList<>();
|
|
|
|
+ list.add("1");
|
|
|
|
+ list.add("2");
|
|
map2.put("key","3");
|
|
map2.put("key","3");
|
|
- map.put("1",map2);
|
|
|
|
- String spel = "#root['1']['key']";
|
|
|
|
|
|
+ map.put("1",list);
|
|
|
|
+ String spel = "#root['1'][0]";
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
StandardEvaluationContext context = new StandardEvaluationContext(map);
|
|
StandardEvaluationContext context = new StandardEvaluationContext(map);
|
|
// 这里很关键,如果没有配置MapAccessor,那么只能用['c']['a']这种解析方式
|
|
// 这里很关键,如果没有配置MapAccessor,那么只能用['c']['a']这种解析方式
|
|
- System.err.println(parser.parseExpression(spel).getValue(context));
|
|
|
|
|
|
+ System.out.println(parser.parseExpression(spel).getValue(context));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|