Struts OR Tiles OR ???...... JSP 模板解决方案
目前我正在使用 JSP 模板系统,该系统使用 这个示例lib(“/WEB-INF/tlds/template.tld”)。
我什至不知道它怎么称呼。
无论如何,它似乎不太发达,它使表单 POST 方法出现问题,我不知道是谁制作的(只是找到它),而且我听说过 Apache 的 Struts & 。瓷砖。
我什至不确定 Struts 是否能实现我所说的功能。
言归正传:
我网站中的一个页面有这个 JSP 内容,它使用了模板:
<%@ 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>
模板是:
<%@ 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>
因此,正如您所看到的,每个页面都为模板提供了一些参数,并且一切都很好。
是否有一个“完善的”系统可以做到这一点?我确信有;它的名字是什么?您可以将其用于非常简单的页面,但是必须支持带有代码的动态页面(JSP)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
四元数是对的,Tiles 和 SiteMesh 都是非常流行的装饰框架。您还可以使用 JSP .tag 文件来实现此目的,如下所示 在此答案中。
我从未使用过 SiteMesh,但我在工作中参与过几个使用 Tiles 的项目,但我并不关心它——对我来说,它只是一个额外的层,并没有带来足够的物超所值。标记文件的另一个好处是它是 JSP 的内置部分。
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.
Apache Tiles 和 Sitemesh 是两个最流行的系统。 Tiles 更符合您所演示的内容。
Apache Tiles and Sitemesh are the two most popular systems. Tiles is more in keeping with what you demonstrated.