使用 Apache Tiles 包含部分图块?
我和瓷砖相处得很艰难。
我有一个带有许多视图的网络应用程序,所有这些都是围绕一个模板组成的。该模板大约有三个或四个“占位符”,对于每个视图,不同的动态生成的内容应放置在正确的占位符中。
当我使用 Tiles 定义新视图时,我需要创建多个 JSP 文件 - 每个文件都有一个占位符内容。然后我需要更新一个巨大的 XML 文件,其中有很多看起来完全相同的条目。
我正在寻找一种解决方案,允许我在同一文件中声明所有这些占位符的内容,并将该文件部分包含到模板中(每个片段都包含在其占位符中)。
我也在研究 Velocity 和 FreeMarker,但它们似乎都没有部分包含功能。
我在这里有什么选择?我愿意考虑改变框架,只是为了让创建另一个视图变得不那么乏味。
谢谢!
I'm having a hard time with Tiles.
I have a webapp with many views, all of these are composed around a single template. The template has about three or four "placeholders", and for each view, different, dynamically generated content should be placed in the correct placeholder.
When I define a new view with Tiles I need to create multiple JSP file - each with a placeholder's content. Then I need to update a huge XML file that has a lot of entries that look just the same.
I'm looking for a solution that'll allow me to declare all these placeholder's content in the same file, and partially include this file into the template (every fragment to its placeholder).
I was looking at Velocity and FreeMarker as well, but either of these doesn't seem to have a partial-include feature.
What are my options here? I'm willing to consider a change of framework just to make it a little less tedious to create yet another view.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您的 xml 文件很大的原因是因为您可能没有扩展默认模板,如下所示
这应该是您的基本模板:
现在您有了一个基本模板,您可以按如下方式扩展它:
这个新页面将包括应用程序基础和主页的 CSS 样式表
这有帮助吗?
I believe the reason why your xml file is huge is because you might not have extended the default template as follow
This should be your base template:
Now that you have a basic template you can EXTEND it as follow:
This new page is going to include both css stylesheets of the app base and the home page
Is this of help?