在 Java 中等效的 ASP.NET 母版页 [英] ASP.NET Master Pages equivalent in Java

查看:18
本文介绍了在 Java 中等效的 ASP.NET 母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Java Web 开发世界中,Master Pages 相当于什么?我听说过 Tiles、Tapestry 和 Velocity,但对它们一无所知.它们是否像母版页一样易于使用?

What would be the Master Pages equivalent in the Java web development world? I've heard of Tiles, Tapestry and Velocity but don't know anything about them. Are they as easy to use as Master Pages?

我想要一些简单的东西,比如设置一个模板,然后从模板派生出后续页面并覆盖内容区域,类似于母版页.

I want something as easy as set up one template and subsequent pages derive from the template and override content regions, similar to Master Pages.

任何例子都会很棒!!

推荐答案

首先,Java 中 ASP.Net 的等价物将是一个 Web 框架,例如您提到的那些(Tiles、Tapestry 和 Velocity).

First, the equivalent of ASP.Net in Java is going to be a web framework, such as the ones you mention (Tiles, Tapestry and Velocity).

母版页能够根据插入母版模板的内容来定义页面.

Master pages give the ability to define pages in terms of content slotted into a master template.

母版页是 ASP.Net(.Net Web 框架)的一项功能,因此您正在寻找类似于 Java Web 框架中母版页的功能.

Master pages are a feature of ASP.Net (the .Net web framework), so you are looking for a feature similar to master pages in a Java web framework.

http://tiles.apache.org/framework/tutorial/basic/pages.html 给出了一些使用 Tiles 和 JSP 来实现与 Java Web 框架 Struts 类似的基本示例.在这种情况下,母版页功能是 Struts 之上的插件.

http://tiles.apache.org/framework/tutorial/basic/pages.html gives some basic examples using Tiles and JSP to implement something similar with Struts, a Java web framework. In this case, the Master Pages functionality is a plugin on top of Struts.

Velocity 是一个通用的模板引擎,不是专门用于网页的,而且绝对比您需要的更复杂.(我已经看到它用于代码生成.)

Velocity is a generic templating engine, not specialized for web pages and definitely more complicated than you need. (I've seen it used for code generation.)

Tapestry 比 Tile 更像是一个功能齐全的网络堆栈,并且可能适合您的目的.它的模板功能包括创建一个组件并将所有常见的标记放入其中.一个例子是在 http://www.infoq.com/articles/tapestry5-intro.

Tapestry is more of a full featured web stack than Tile, and is probably good for your purposes. Its templating functionality involves creating a component and putting all common markup in that. An example is at http://www.infoq.com/articles/tapestry5-intro.

具体情况因您选择的 Java 网络框架而异.

The specifics of this differ based on which Java web framework you choose.

这篇关于在 Java 中等效的 ASP.NET 母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆