JSP模板继承 [英] JSP template inheritance
问题描述
从Django的背景出发,我经常使用模板继承,其中多个模板从公共基础继承。在JSP中有简单的方法吗?如果没有,是否有JSP的替代方法(除了Jython上的Django是:)
Coming from a background in Django, I often use "template inheritance", where multiple templates inherit from a common base. Is there an easy way to do this in JSP? If not, is there an alternative to JSP that does this (besides Django on Jython that is :)
<html>
<body>
{% block content %}
{% endblock %}
</body>
<html>
基本内容
basic content
{% extends "base template" %}
{% block content %}
<h1>{{ content.title }} <-- Fills in a variable</h1>
{{ content.body }} <-- Fills in another variable
{% endblock %}
将呈现如下(假设conten.title是Insert Title Here,而content.body是Insert Body Here)
Will render as follows (assuming that conten.title is "Insert Title Here", and content.body is "Insert Body Here")
<html>
<body>
<h1>Insert title Here <-- Fills in a variable</h1>
Insert Body Here <-- Fills in another variable
</body>
<html>
推荐答案
你可能想查看瓦片。
编辑:在相关注释瓷砖,您可能需要查看 Struts 。这不是你正在寻找的(那是瓷砖),但它对来自Django的人来说很有用。
On a related note to tiles, you might want to look into Struts. It's not what you're looking for (that's tiles), but it is useful for someone coming from Django.
这篇关于JSP模板继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!