Simplified website development: SiteMesh plug-in and sitemesh for website development

Source: Internet
Author: User
Tags blizzard

Simplified website development: SiteMesh plug-in and sitemesh for website development

When writing a website, almost all pages have the same part. For example, in the top navigation bar, each page is the same, and the copyright statement at the bottom is the same for each page.

When writing the top navigation bar, the first method is to directly copy all the code in the navigation bar. This method is easy to develop at the beginning, but it is a nightmare to maintain it later. If you want to add a button in the navigation bar, it is very troublesome to modify all pages.

The second method is to write the top navigation bar to a file and include the file on all pages. In this way, an include statement is required for each page. Only one file can be modified later. However, the navigation bar file written in this method is not a complete webpage. In addition, it is troublesome to write the include statement on each file.

To make this page easier to write, SiteMesh came into being.

SiteMesh solves this problem through the decorator mode. The following describes how to use the decorator.

Installation Method

Step 1 place sitemesh. xxx. jar in/WEB-INF/lib.

Step 2 Add the SiteMesh filter to web. xml.

<filter>  <filter-name>sitemesh</filter-name>  <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class></filter> <filter-mapping>  <filter-name>sitemesh</filter-name>  <url-pattern>/*</url-pattern></filter-mapping>

It should be noted that if you want to use it with struts, filter-mapping must be later than struts so that it can be decorated according to the file name; otherwise, it is decorated according to the action name. In addition, add the following three lines to filter-mapping to make struts decorate the file before accessing jsp. If it is not added, the decoration effect will not be visible.

<dispatcher>REQUEST</dispatcher><dispatcher>FORWARD</dispatcher><dispatcher>INCLUDE</dispatcher>

Step 3: Create a modifier definition file. The file is located in/WEB-INF/decorators. xml. The content is as follows:

<?xml version="1.0" encoding="UTF-8"?><decorators></decorators>

In this way, the SiteMesh plug-in is installed.

Use of plug-ins

First, write a very simple decorator file. Its function is to add header and footer at the beginning and end of the page. The function of \ texttt {decorator: body} is to import the real content into the file.

<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>

Step 2 declare the decorators in decorators. xml.

<?xml version="1.0" encoding="UTF-8"?><decorators defaultdir="/WEB-INF/decorators">    <decorator name="basic-theme" page="basic-theme.jsp">        <pattern>/test.jsp</pattern>    </decorator></decorators>

Because web. xml has been modified, You need to restart the server to see the effect. You will see that header and footer are added to the header and tail of test. jsp.


WOW takes the initiative to simplify plug-ins

Lucidity ultra-simple action bar plug-in
This removes the blizzard design, but it is very small and only 3.6 K

NMainbar beautiful and compact action bar plug-in
The blizzard design is retained, and the 2-row action bar is changed to the 3-row action bar.

The BarKeep action bar enhancement plug-in is based on the built-in action bar plug-in of blizzard. It allows you to change the number of rows, columns, scaling, location, and display of any action bar. Enter "/BarKeep" or set it in the plug-in panel of the Interface Options.

These plug-ins are very small. I don't know which one you want. The second one is suitable for you.

How can we simplify the 3dmax mesh model? Who can provide a simplified plug-in download link? 50 points

There is an optimization function in the modification.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.