为什么调用power方法报错 public class MyIntegerExt { public Integer square(Integer self) { return self * self; } public Double power(Integer self, Double exponent) { return Math.pow(self, exponent); } public Boolean isOdd(Integer self) { return self % 2 != 0; } } //配置Integer扩展方法 Engine.addExtensionMethod(Integer.class, MyIntegerExt.class); #set(num = 123) #(num.square()) #(num.power(10))//报错 #(num.isOdd())
解决方法:
数字常量:123 456F 789L 0.1D 0.2E10 //1.double参数 Double power(Integer self, Double exponent) #set(num = 123) #(num.square()) #(num.power(10.0))或者#(num.power(10D)) #(num.isOdd()) //2.Integer参数 Double power(Integer self, Integer exponent) #set(num = 123) #(num.square()) #(num.power(10)) #(num.isOdd())
项目:JFinal