1
我最近開始學習Tapestry框架。我正在關注如何創建自定義組件並在代碼中使用它。出於某種原因,組件中的文本沒有顯示(我只看到hello world文本)。這裏是的.java和TML文件:在掛毯中使用自定義創建的組件
public class Index
{
public Index() {
}
public String getHello()
{
return "Hello world!";
}
}
指數TML:
<html xmlns:t="http://tapestry.apache.org/schema/
tapestry_5_3.xsd">
<head>
<title>Tapestry 5 Book</title>
</head>
<body>
<t:MyComponent/>
<h1> ${hello} </h1>
</body>
</html>
MyComponent.java
public class MyComponent {
public String getStuff()
{
return "Random stuff";
}
}
MyComponent.tml
<span> ${stuff} </span>
我也想說.java文件在他們的對應文件中修復程序包(main/java中的頁面和組件)和.tml文件位於其相應的資源包中。我的問題是,爲什麼組件文本沒有顯示?
那麼這個文件夾裏我可以找到MyComponent.tml文件 src \ main \ resources \ com \ example \ tutorial \ components – Dvorog
我也在MyComponent構造函數中放了一個System.out.println行來測試構造函數被調用。構造函數未被調用。 – Dvorog
下一步是在啓動時發佈控制檯輸出;它列出了Tapestry在啓動時識別的所有頁面和組件。 –