JSP template inheritance

前端 未结 6 862
太阳男子
太阳男子 2020-12-13 14:13

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

6条回答
  •  盖世英雄少女心
    2020-12-13 14:52

    My favorite Java web front-end tech is Facelets. It supports the most Django-like templating I've seen. It's not quite as clean as Django's, but you get the same inheritance benefits.

    Instead of Django's:

    Super:

    {% block content %}{% endblock %}
    

    Sub:

    {% block content %}inheriting template's content here{% endblock %}
    

    Facelet's syntax is like this:

    Super:

    
    

    Sub:

    inheriting template's content here
    

提交回复
热议问题