1 | <abc:displayDate /> |
1 2 3 4 | <abc:tagWithNoBody attribute="value"/> <abc:tagWithBody attribute="value"> This is some body content that the tag handler can operate upon. </abc:tagWithBody> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | package myTags; import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.*; import javax.servlet.http.*; import java.text.*; import java.util.*; public DateTag extends TagSupport { public int doStartTag() throws javax.servlet.jsp.JspException { HttpServletRequest req; Locale locale; HttpJspPage g; DateFormat df; String date; JSPWriter out; req = ( HttpServletRequest )pageContext.getRequest(); locale = req.getLocale(); df = SimpleDateFormat.getDateInstance( SimpleDateFormat.FULL,locale ); date = df.format( new java.util.Date() ); try { out = pageContext.getOut(); out.print( date ); } catch( IOException ioe ) { throw new JspException( "I/O Error : " + ioe.getMessage() ); }//end try/catch return Tag.SKIP_BODY; }//end doStartTag() }//end DateTag |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |