Class Foo
{
public String currentVersion()
{
return "1.2";
}
}
需要從使用JSP標籤庫調用CURRENTVERSION類的方法調用JSP類的方法? currentversion不是getter或setter方法,它只是一個類方法。使用JSP標籤
Class Foo
{
public String currentVersion()
{
return "1.2";
}
}
需要從使用JSP標籤庫調用CURRENTVERSION類的方法調用JSP類的方法? currentversion不是getter或setter方法,它只是一個類方法。使用JSP標籤
您不能使用標準JSP表達式(如${foo.currentVersion}
)執行此操作,該表達式僅適用於bean特權(即getCurrentVersion()
)。
你需要或者
Foo
調用currentVersion()
自定義標籤種類有getCurrentVersion()
方法只需將您的方法重命名爲getCurrentVersion()
,there is nothing in the JavaBeans specification that says that a "getter" method has to return the value of an attribute on the class。一個getter方法可以像你一樣簡單地返回一個常量值。
class Foo {
public String getCurrentVersion() {
return "1.2";
}
}
我該如何編寫自定義標籤以調用該方法? – 2010-02-09 16:15:44
http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html – skaffman 2010-02-09 16:30:28
Blah,當我看到這個時,我有一種感覺,那就是答案。我真的不想寫自己的自定義標籤類。 – Powerlord 2010-10-01 17:43:44