Soon after entering the new company, today in the project to see the use of the. tag file. At first I thought this was a third party template technology similar to Freemarker. Asked the other team members of the project, originally this is jsp2.0 since the JSP fragment technology. Never used to do projects in such a way, to use the use of JSP in the Include and Jsp:include way. In fact, JSP fragment also has the role of include, but it is more like Third-party Sitemesh technology, for Web page layout and decoration, can be the content of the page and the structure of the page to separate, so as to achieve the purpose of sharing page structure. The following example shows how to use JSP fragment.
Official e-Text Reference document Http://docs.oracle.com/javaee/5/tutorial/doc/bnama.html
DEMO
1 first in the project's Web-inf/tags file, create a new Tpl.tag file that reads
<%@ tag language= "java" pageencoding= "UTF-8"%> <%@ attribute name= "title"%> <%@ attribute name= "TPL1" fra Gment= "true" required= "true"%> <%@ attribute name= "TPL2" fragment= "true" required= "true"%> attribute Name= "Tpl3" fragment= "true" required= "true"%> DOCTYPE html>
2 Creating index.jsp Files
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <%@ taglib prefix=" Xjo "tagdir="/web-inf/tags "%> <xjo
: TPL title= "Use of JSP tag files" >
<jsp:attribute name= "TPL1" >
3 Access to index.jsp page, the effect is as follows
This column more highlights: http://www.bianceng.cn/webkf/JSP/