Usage of the Pagedecoratormapper mapper for Sitemesh2-sitemesh.xml

Source: Internet
Author: User

In the example used in the previous chapter http://www.cnblogs.com/EasonJim/p/7083165.html, the Decorators.xml file is converted via URL matching.

The following method is converted through the Sitemesh.xml pagedecoratormapper mapper without matching the URL, just specify the template in the Meta header decorator.

Here are the steps to proceed:

1. Add the Pagedecoratormapper Mapper to the Sitemesh.xml and specify the meta name rule

        <Mapperclass= "Com.opensymphony.module.sitemesh.mapper.PageDecoratorMapper">            <param name= "property.1" value= "Meta.decorator"/>            <paramname= "property.2"value= "Decorator" />            <!--Note that this line specifies the name attribute of the <meta/> tag as the identifier for the Pagedecorator -            <param name= "property.3" value= "Meta.theme"/>        </Mapper>

Usage:

①<meta name= "Decorator" content= "Basic-theme"/>

②<meta name= "Them" content= "Basic-theme"/>

③<param name= "property.2" value= "decorator"/> This usage temporarily does not know how to use.

Note: The content specifies the name of the template that is docorator in the Decorators.xml file.

2, in the Decorators.xml template configuration or use the original

<defaultdir= "/decorators">    <decorator name= " Basic-theme "page=" basic-theme.jsp ">        <pattern>/data/*< /pattern>    </decorator></  decorators>

3, the new index.jsp page in the root directory, the content is as follows:

<%@ Page Language="Java"ContentType="text/html; Charset=utf-8" pageencoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><meta name= "decorator" content= "Basic-theme"/><title>Should be the content page</title></Head><Body>    <H1>Weekdays</H1>    <P>5:00pm-10:00pm</P>    <P>Weekends</P>    <P>5:00pm-10:00pm</P></Body></HTML>

4, the test results are as follows:

Test Project: Https://github.com/easonjim/5_java_example/tree/master/sitemesh/test2

Reference:

Http://wiki.sitemesh.org/wiki/display/sitemesh/Decorating+Beyond+URL+Patterns

https://my.oschina.net/yangning/blog/110487

Usage of the Pagedecoratormapper mapper for Sitemesh2-sitemesh.xml

Related Article

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.