没什么呀
java:
public class FirstTag extends TagSupport
{
/* (非 Javadoc)
* @see javax.servlet.jsp.tagext.Tag#doEndTag()
*/
public int doStartTag() throws JspException
{
// get the locale of the client and create an appropriate date format
Locale loc = pageContext.getRequest().getLocale();
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, loc);
try
{
// and write out the formatted date to the page
pageContext.getOut().write(df.format(new Date()));
}
catch (java.io.IOException ioe)
{
throw new JspTagException(ioe.getMessage());
}
// and skip evaluating the body of the tag (as there shouldn't be one)
return SKIP_PAGE;
}
}
my-tag.lib
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>simple</short-name>
<description>Examples for the Simple Tags chapter</description>
<tag>
<name>date</name>
<tag-class>com.chinsoft.mytag.FirstTag</tag-class>
<body-content>empty</body-content>
<description>Inserts the current date into the page</description>
</tag>
修改一处即可。
throw new JspTagException(ioe.getMessage());
}
// and skip evaluating the body of the tag (as there shouldn't be one)
return SKIP_PAGE;//这应该是return SKIP_BODY;
}
}