Using Sitemesh to build a composite view-3. Other discussions

Source: Internet
Author: User
Tags character set
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:)



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.