我最近开始学习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文件在其相应的资源包中。我的问题是,为什么组件文本没有显示?
发布于 2015-06-05 01:02:24
在我看来一切都很好,所以这实际上只是绝对验证MyComponent.tml是否在正确的位置,以及在运行时在类路径上是否可见。例如,这可能是IDE配置的问题。
对于组件类资源,典型的位置是src/main/resources/org/example/MyComponent.tml,,但您必须确保您的集成开发环境在src/ org.example.MyComponent /org.example.MyComponent中导出文件。
https://stackoverflow.com/questions/30646146
复制相似问题