//无正文标签类继承的是TagSupport类 实现的接口是Tag。 如果有正文的标签类继承的是BodyTagSupport类 实现的接口是BodyTag public class DateTagNoBody extends TagSupport { private static final long serialVersionUID = 1L;
private String pattern;
@Override public int doStartTag() throws JspException { HttpServletRequest request; // 是TagSupport类中定义的一个属性,它是javax.servlet.jsp.PageContext的对象 request = (HttpServletRequest) pageContext.getRequest(); java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat( pattern); String date = formater.format(new Date()); JspWriter out = pageContext.getOut(); try {