Spring & Tiles - 摆脱 tiles.xml

标签 spring configuration tiles

我有一个 Tiles 模板,其中每个页面都提供一个标题,一些要添加到 <head> 中的内容,要放入一些混凝土的东西<div> ,以及附加到 <body> 的内容在一切之后。

大部分内容都非常小,因为页面是用 JS 呈现的。

我怎样才能去掉 tiles.xml还是让它更易于管理?

我不希望每个页面都需要 3 个文件:

<definition name="my_page" template="/template.jsp">
    <put-attribute name="title" value="My Title" />
    <put-attribute name="head" value="/tiles/my-head.jsp" />
    <put-attribute name="body" value="/tiles/my-page.jsp" />
    <put-attribute name="body-append" value="/tiles/my-append.jsp" />
</definition>

而且我不想把所有页面的内容都放在tiles.xml中。

理想情况下,它会简单地将 my_page 重定向到 /my_page.jsp它将自己导入和填充模板。

我说的是 TilesView 的 Spring 应用程序.

最佳答案

您可以直接在 JSP 中使用 tiles JSP 标记。如果您不想,则不必使用定义。

在您的 my_page.jsp 中:

<tiles:insertTemplate template="/template.jsp" flush="true">
<tiles:putAttribute name="title" value="My Title" />
<tiles:putAttribute name="head" value="/tiles/my-head.jsp" />
... etc
</tiles:insertTemplate>

参见 http://tiles.apache.org/framework/tiles-jsp/tlddoc/index.html

关于Spring & Tiles - 摆脱 tiles.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6825828/

相关文章:

php - Zend Framework 将开发人员特定的环境信息与配置分开?

node.js - 有没有类似 JSP 的 node.js 模板引擎?

java - Spring 应用程序似乎没有持久化数据

PHP 文件由浏览器下载,而不是由本地开发服务器 (MAMP) 处理

java - Mysql,Hibernate - 插入表时,它说字段没有默认值

windows - Windows 注册表中 DefaultConnectionSettings 值的格式是什么?

android - 如何使用 LibGdx 在 Tilemap 中制作动画?

java - Spring MVC 和 Rest : different "layout" with same "content"?

java - MongoDB Autowiring 抛出异常

json - spring序列化 Autowiring 字段