Author: Chen-neu, provided
Huihoo.com released)
Use sitemesh to create a composite view-1. Hello <-now
Create a composite view using sitemesh-2. decorator
Use sitemesh to create a composite view-3. Other discussions
Sitemesh is one of the J2EE application frameworks developed by the opensymphony team. It aims to improve the maintainability and reusability of pages. Another widely-known framework of opensymphony is webwork, which is used as a web layer representation framework. They are all open-source and can be found at www.sf.net.
An example of a large project: http://opensource.thoughtworks.com/projects/sitemesh.html
- Www.jboss.org
- Www.theserverside.com
- Www.opensymphony.com
- Www.atlassian.com
Introduction: |
Sitemesh uses the decorator mode to intercept requests and response with filters, and combine the page components head, content, and banner into a complete view. We usually use the include tag to continuously include various headers, stylesheet, scripts and footer in each JSP page. Now, with the help of sitemesh, we can happily delete them. For example, if you want to easily achieve the composite view mode, read this article. |
Hello sitemesh: |
- In WEB-INF/Web. XML, copy the following filter definitions:
sitemesh
COM. opensymphony. module. sitemesh. filter. pagefilter
sitemesh
/*
sitemesh-decorator
/WEB-INF/sitemesh-decorator.tld
sitemesh-page
/WEB-INF/sitemesh-page.tld
|
- Copy the required jar and DTD files to the corresponding directory and access CVs of opensymphony.sourceforge.net to get the latest sitemesh version.
Sitemesh. Jar |
WEB-INF/lib |
Sitemesh-decorator.tld |
WEB-INF |
Sitemesh-page.tld |
WEB-INF |
-
- Create a WEB-INF/decorators. XML to describe the decoration pages (which can be modeled in the sitemesh example ).
<Decorators defaultdir = "/_ decorators"> <decorator name = "Main" page = "Main. JSP "> <pattern> * </pattern> </decorator> </decorators> |
- Create a decorators page/_ decorators/Main. jsp
<% @ page contenttype = "text/html; charset = GBK "%> <% @ taglib uri =" sitemesh-decorator "prefix =" decorator "%> <decorator: title default = "decorator page... "/>
sitemesh example
chen56@msn.com |
- Create a decoration page/index. jsp (Content Page)
<% @ Page contenttype = "text/html; charset = GBK "%> <HTML> |
Finally, access index. jsp to generate the following page: In addition, all pages will be changed to the same decoration mode as index. jsp by the filter of sitemesh, without the need to use the include tag. |