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