index.jsp文件的内容
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="tld/mytag" prefix="mytag"%>
Insert title here
自定义标签处理类:
package cn.test.tag;
import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;
public class Hello extends TagSupport {
public int doEndTag() throws JspException {
try{
JspWriter out=pageContext.getOut();
out.println("AAA");
}catch (IOException e){
e.printStackTrace();
}
return EVAL_PAGE;
}
}
mytag.tld 文件的内容
"">
1.0
1.2
mytag
hello
cn.test.tag.Hello
web.xml文件的内容
index.jsp
tld/mytag
/WEB-INF/tld/mytag.tld
阅读(1447) | 评论(0) | 转发(0) |