Class Foo
{
   public String currentVersion()
   {
     return "1.2";
   }
}


需要使用标签库从jsp调用currentVersion类方法?在currentversion不是getter或setter方法的地方,它只是一个类方法。

最佳答案

您不能使用像${foo.currentVersion}这样的标准JSP表达式来执行此操作,该表达式仅适用于bean属性(即getCurrentVersion())。

你需要


编写脚本(不要这样做!)
编写一个自定义标签类,为您调用currentVersion()
重构Foo以具有getCurrentVersion()方法

09-11 18:47