Skip to content

Commit f004e39

Browse files
committed
🎉 add tag customer
1 parent c04069d commit f004e39

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

WebRoot/WEB-INF/tld/tag.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!DOCTYPE taglib
3+
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
4+
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
5+
6+
<taglib>
7+
8+
<!-- tlib 全局信息 -->
9+
<tlib-version>1.0</tlib-version><!-- 代表标签库的版本号 -->
10+
<jsp-version>1.2</jsp-version><!-- 代表jsp的版本 -->
11+
<short-name>ucaner</short-name><!-- 你的标签库的简称 -->
12+
<uri>http://tag.ucaner.cn/jason</uri><!-- 你标签库的引用uri -->
13+
14+
<!-- 自定义标签对 -->
15+
<tag>
16+
<name>tag</name><!-- 你定义的标签的名称 -->
17+
<tag-class>cn.ucaner.core.tag.custag.MyTag</tag-class><!-- 对应的标签处理程序:包名+类名 -->
18+
<body-content>JSP</body-content><!-- 标签体内容的格式 -->
19+
</tag>
20+
21+
</taglib>

WebRoot/WEB-INF/views/jsp/tag.jsp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- 引入自定义标签对 -->
2+
<%@taglib uri="http://tag.ucaner.cn/jason" prefix="ucaner" %>
3+
4+
<html>
5+
<head>
6+
<title>This is My Coustomer Tag. -{ucaner:tag} Just For Test </br> -- by Jason</title>
7+
</head>
8+
<body>
9+
<ucaner:tag></ucaner:tag>
10+
</body>
11+
</html>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* <html>
3+
* <body>
4+
* <P> Copyright 1994-2018 JasonInternational </p>
5+
* <p> All rights reserved.</p>
6+
* <p> Created on 2018年5月5日 下午3:11:25</p>
7+
* <p> Created by Jason</p>
8+
* </body>
9+
* </html>
10+
*/
11+
package cn.ucaner.core.tag.custag;
12+
13+
import java.io.IOException;
14+
15+
import javax.servlet.jsp.JspException;
16+
import javax.servlet.jsp.PageContext;
17+
import javax.servlet.jsp.tagext.TagSupport;
18+
19+
/**
20+
* @Package:cn.ucaner.core.tag.custag
21+
* @ClassName:MyTag
22+
* @Description: <p> MyTag </p>
23+
* @Author: - Jason
24+
* @CreatTime:2018年5月5日 下午3:11:25
25+
* @Modify By:
26+
* @ModifyTime: 2018年5月5日
27+
* @Modify marker:
28+
* @version V1.0
29+
*/
30+
public class MyTag extends TagSupport{
31+
32+
private static final long serialVersionUID = -1072447572747287532L;
33+
34+
private PageContext pageContext;
35+
36+
@Override
37+
public void setPageContext(PageContext pageContext) {
38+
this.pageContext=pageContext;
39+
}
40+
41+
@Override
42+
public int doStartTag() throws JspException {
43+
try {
44+
pageContext.getResponse().getWriter().write("This is My Customer Tag Just for test By Jason!");
45+
} catch (IOException e) {
46+
e.printStackTrace();
47+
throw new RuntimeException(e);
48+
}
49+
return super.doStartTag();
50+
}
51+
}

0 commit comments

Comments
 (0)