ソースを参照

下标取值支持 Number 类型

James 5 年 前
コミット
06bfc6fa1d
1 ファイル変更3 行追加3 行削除
  1. 3 3
      src/main/java/com/jfinal/template/expr/ast/Index.java

+ 3 - 3
src/main/java/com/jfinal/template/expr/ast/Index.java

@@ -76,10 +76,10 @@ public class Index extends Expr {
 		}
 		
 		if (target.getClass().isArray()) {
-			if (idx instanceof Integer) {
-				return java.lang.reflect.Array.get(target, (Integer)idx);
+			if (idx instanceof Number) {
+				return java.lang.reflect.Array.get(target, ((Number)idx).intValue());
 			}
-			throw new TemplateException("The index of array must be integer", location);
+			throw new TemplateException("The index of array must be Number", location);
 		}
 		
 		throw new TemplateException("Only the list array and map is supported by index access", location);