Struts OR Tiles OR ???… JSP template solution

佐手、 提交于 2020-01-01 19:37:27

问题


currently I'm using a JSP templating system which uses this example's lib ("/WEB-INF/tlds/template.tld").

I'm not even sure how it's called.

Anyway it seems like it's not too developed, it makes problems with form POST method, I have no idea who made it (just found it) and I've heard about Apache's Struts & Tiles.

I'm not even sure that Struts does what I'm talking about.

Down to business:
A page in my site has this JSP content, that utilizes the template:

<%@ taglib uri="/WEB-INF/tlds/template.tld" prefix="template"%>
<template:insert template="/WEB-INF/main_template_page/template.jsp">
    <template:put name="title" content="Title here" direct="true" />
    <template:put name="content" content="/content.jsp" />
</template:insert>

The template is:

<%@ taglib uri='/WEB-INF/tlds/template.tld' prefix='template'%>
<html>
<head>
<title>
    <template:get name='title' />
</title>
<link type="text/css" rel="stylesheet" href="/styles.css" />
</head>

<body>

    <div id="div_header">
        <div class="content">
            <%@include file='header.html'%>
        </div>
    </div>

    <div id="div_content">
        <template:get name='content' />
    </div>

    <div id="div_footer">
        <%@include file='footer.html'%>
    </div>

</body>
</html>

So as you see each page gives the template some parameters and it all works nice.

Is there a "well-established" system that does that? I'm sure there is; What its name? Which would you use for pretty much simple pages, but, has to support dynamic ones with code (JSP).


回答1:


Quaternion is right that Tiles and SiteMesh are both pretty popular decoration frameworks. You can also use JSP .tag files to achieve this, as shown in this answer.

I've never used SiteMesh, but I've worked on several projects at work that use Tiles and I don't care for it -- to me it's just an extra layer that doesn't add enough bang-for-my-buck. Tag files have the added bonus of being a built-in part of JSP.




回答2:


Apache Tiles and Sitemesh are the two most popular systems. Tiles is more in keeping with what you demonstrated.



来源:https://stackoverflow.com/questions/7155998/struts-or-tiles-or-jsp-template-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!