In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
1. Introduction of SiteMesh
SiteMesh is a web layout and retouching framework for a Java WEB project. With SiteMesh, you no longer need to introduce other common pages such as headers, footers, navigation, and so on, with tags in each page.
The content of the web page can be separated from the page structure to achieve the purpose of page structure sharing.
The page decoration effect is coupled in the target page, there is no need to use the include instruction to display the decoration effect, and the target page and the decoration page are completely separated.
The whole web application can use the same decorative page with a uniform style and a better overall effect.
SiteMesh intercepts requests and responses through Filter, adds decoration to the original page, and then returns the decorated results to the client.
Find the appropriate decorative template page according to the page URL matching rules
Extract the contents of the visited page and place it in the appropriate location in the decoration template.
2. Use of business scenarios
For example, the common is the crm system, the tree menu on the left is consistent, the main part of the change on the right (that is, the decorated page).
Third, the working principle of SiteMesh
Sitemesh uses Decorator mode, intercepts request and response with filter, and combines page components head,content,banner and bottom into a complete view. Usually we use include tags in each jsp page to constantly include a variety of header, stylesheet, scripts and footer. See the picture below
When the user requests home.jsp and the server is ready to return data after processing, it is intercepted by SiteMesh Filter and wraps the data into a Page object, specifically a call to Page page = parsePage (request, response, chain), and then it queries the decorators.xml file to see if the page needs to be decorated [if (decorator! = null & & decorator.getPage ()! = null)]? Yes, apply the decorator [applyDecorator (page, decorator, request, response)], otherwise, send the original undecorated page [writeOriginal (response, page);].
IV. Sitemesh application configuration
First we need to go to http://www.opensymphony.com/sitemesh/ to download the jar package we need: sitemesh-2.4.jar
Then it is divided into three steps: the first step: web.xml configuration; the second step: decorate.xml configuration; the third step: decorating the page
4.1 web.xml configuration
Sitemesh com.opensymphony.sitemesh.webapp.SiteMeshFilter sitemesh / *
4.2 decorate.xml configuration
Create a new decorators.xml file under the WEB-INF directory (/ decorator is your packaging jsp root path where main.jsp and panel.jsp are both packaging jsp,a.jsp,b,jsp is packaged jsp)
/ resources/** / system/login_index.do / system/login.do / system/close_window.do / system/login_force.jsp / system/info.jsp / index.jsp / usermemcached/** / * *
Use decrator to specify the correspondence between the decoration template and URL, or you can configure those URL with excludes that do not require template control.
4.3 decorate the page
> X.
Parameter description:
Populate the head tag content of the decorated page
Populate the body tag content of the decorated page
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.