错误: MyExchangeClass 类型中的方法 exchangeConversion(String, String, float) 不适用于参数 (String, String, double)
jsp 文件中的代码,15.4 和 15.4f 也有错误,但如果更改函数和 TLD 为 double 都可以正常工作。为什么 15.4 和 15.4f 就像是双打一样?
...
From GBP to USD: ${ elfuncs:exchange("GBP", "USD", 15.4f) }
Otherwise: ${ elfuncs:exchange("GBP", "YEN", 15.4) }
TLD 中的代码
<function>
<name>exchange</name>
<function-class>mypackage.MyExchangeClass</function-class>
<function-signature>float exchangeConversion(java.lang.String, java.lang.String, float)</function-signature>
</function>
java 类的代码 public class MyExchangeClass {
public static float exchangeConversion(String from, String to, float amount) {
float calculatedAmount = 0.0f;
/* Example implementation code: */
if(from.equals("GBP") && to.equals("USD")) {
calculatedAmount = amount*1.5f;
}
return calculatedAmount;
}
}