View
The previous article is enough to apply Sitemesh to improve your application, but I find that there are other things that might help.
Printable interface Decoration previously said there are 1 types of printable adorners that allow you to use the other adorners (specified by yourself) when you access them in http://localhost/aaa/a.html?printable=true mode, giving the original page for printing ( Lest the fancy pictures of Header,footer etc be hooked up too.
Let's take a look at how to achieve him:
1. First set in Web-info/sitemesh.xml:
<mapper class= "Com.opensymphony.module.sitemesh.mapper.PrintableDecoratorMapper" >
<param name= "decorator" value= "printable"/>
<param name= "parameter.name" value= "Printable"/>
<param name= "Parameter.value" value= "true"/>
</mapper>
This allows you to use the adorner named printable instead of the original adorner by using the printable=true.
2. Define the corresponding printable adorner in the Web-info/decorators.xml
<decorator name= "printable" page= "printable.jsp"/>
3. Finally, the preparation of printable adorner/decorators/printable.jsp
<%@ taglib uri= "Sitemesh-decorator" prefix= "decorator"%>
<title><decorator:title/></title>
<decorator:head/>
<body>
<p align= "Right" ><i> (printable version) </i></p>
<decorator:body/>
</body>
This allows an original page to be switched to a different adorner page through the printable=true switch.
Chinese problem because the default character set used in Sitemesh is iso-8859-1, the direct use will produce garbled characters, we can correct it by the following methods:
- Method 1: You can find in the configuration file of the application server you are using, there are no items to set up encoding or CharSet, then set to GBK or gb2312
- Method 2: This is also the method we have been using.
1. In each JSP page set: <%@ page contenttype= "text/html;" CHARSET=GBK "%> to tell the server the character set you requested.
2. Defined in the head of each JSP page: <meta http-equiv= "Content-type" content= "text/html"; CHARSET=GBK "> To tell the browser the character set you are using.
Summary: The most common way to use Sitemesh:
1. Configure the environment,
2. Describe the wrapper you will build in the Web-info/decroators.xml.
3. Develop the packaging described in the decroators.xml, preferably stored in the/_decorators directory
4.ok, you can look at the results of hard work:)