Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Last active March 10, 2019 12:20
Show Gist options
  • Save ezhov-da/6d824530107e157c7022dd094df0d123 to your computer and use it in GitHub Desktop.
Save ezhov-da/6d824530107e157c7022dd094df0d123 to your computer and use it in GitHub Desktop.
java шаблонизатор jsp sitemesh
http://wiki.sitemesh.org/wiki/display/sitemesh/Start+Using+SiteMesh+in+10+Minutes
<h4>ВАЖНО! Некорректная кодировка в файле html, пока не нашел решения проблемы.</h4>
Создаем шаблон:
[code:]html[:code]<?xml version="1.0" encoding="UTF-8" ?>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h1>Header</h1>
<p><b>Navigation</b></p>
<hr />
<decorator:body />
<hr />
<h1>Footer</b></h1>
</body>
</html>
[/code]
Создаем файл декоратор:
<pre>
The last step is to modify or download WebContent/WEB-INF/decorators.xml to,
Reference the decorator basic-theme.jsp
Specify the what resources should be decorated
</pre>
[code:]xml[:code]<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators">
<decorator name="basic-theme" page="basic-theme.jsp">
<pattern>/data/*</pattern>
</decorator>
</decorators>
[/code]
Добавляем фильтр:
[code:]xml[:code]<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
[/code]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment