⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 j-customtags-8-1.html

📁 这是用java编写自定义标签的一些源码和笔记
💻 HTML
📖 第 1 页 / 共 2 页
字号:
  * 

  * @jsp.variable name-from-attribute="id"   class="java.util.Map"   

  *               scope="AT_BEGIN"

  */

 public class MapDefineTag extends TagSupport {

 

     public static final String FASTHASH = "FASTHASH";

     public static final String FASTTREE = "FASTTREE";

     public static final String HASH = "HASH";

     public static final String TREE = "TREE";

     private Map map = null;

     private String type = FASTTREE;

     private String id;

     private String scope;

 

     /* (non-Javadoc)

      * @see javax.servlet.jsp.tagext.Tag#doStartTag()

      */

     public int doStartTag() throws JspException {

 

         if (type.equalsIgnoreCase(FASTTREE)) {

             map = new FastTreeMap();

         } else if (type.equalsIgnoreCase(HASH)) {

           map = new HashMap();

         } else if (type.equalsIgnoreCase(TREE)) {

             map = new TreeMap();

         } else if (type.equalsIgnoreCase(FASTHASH)) {

             map = new FastHashMap();

         }

         

         if (scope == null){

             pageContext.setAttribute(id, map);

         }else if("page".equalsIgnoreCase(scope)){

             pageContext.setAttribute(id, map);

         }else if("request".equalsIgnoreCase(scope)){

             pageContext.getRequest().setAttribute(id, map);

         }else if("session".equalsIgnoreCase(scope)){

             pageContext.getSession().setAttribute(id, map);

         }else if("application".equalsIgnoreCase(scope)){

             pageContext.getServletContext().setAttribute(id, map);

         }

         

         return EVAL_BODY_INCLUDE;

     }

 

     /** Getter for property type.

      * @return Value of property type.

      * @jsp.attribute    

      *    required="false" 

      *    rtexprvalue="false"

      *    description="Specifies the type of map 

        *    valid values are fasttree, fasthash, hash, tree"

      */

     public String getType() {

         return type;

     }

 

     /**

      * @param string

      */

     public void setType(String string) {

         type = string;

     }

 

     /** Getter for property id.

      * @return Value of property id.

      * @jsp.attribute    required="true" 

      *                  rtexprvalue="false"

      *                  description="The id attribute"

      */

     public String getId() {

         return id;

     }

 

     /**

      * @param string

      */

     public void setId(String string) {

         id = string;

     }

     

     public Map getMap(){

         return map;

     }

 

     public void release() {

         super.release();

         map = null;

         type = FASTTREE;

     }

 

     /** Getter for property scope.

      * @return Value of property scope.

      * @jsp.attribute    required="false" 

      *                  rtexprvalue="false"

      *                  description="The scope attribute"

      */

     public String getScope() {

         return scope;

     }

 

     /**

      * @param string

      */

     public void setScope(String string) {

         scope = string;

     }

 

 }

 

 </code>
</pre>
<TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR>
<TD height="1" width="100%">
<spacer height="1" type="block"></spacer>
</TD>
</TR>
<TR>
<TD height="3" width="100%" BGCOLOR="#3333CC" align="left" valign="top"></TD>
</TR>
<TR VALIGN="top">
<TD>
<FORM METHOD="POST" ACTION="/developerWorks/cn/cnratings.nsf/RateOnlineCourse?CreateDocument">
<INPUT value="掌握自定义 JSP 标签" NAME="OnlineCourseTitle" TYPE="HIDDEN"><INPUT NAME="ZONE" TYPE="HIDDEN" VALUE="java"><INPUT NAME="RedirectURL" TYPE="HIDDEN" VALUE="/developerWorks/cn/thankyou/feedback-linux.html"><FONT SIZE="-1" FACE="HELVETICA, HELV, ARIAL"><B>您对这篇文章的看法如何?</B></FONT>
<p>
<TABLE WIDTH="545" CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR VALIGN="top">
<TD><INPUT VALUE="5" NAME="Rating" TYPE="RADIO"><FONT size="-1" FACE="HELVETICA, HELV, ARIAL">真棒!(5)</FONT></TD><TD><INPUT VALUE="4" NAME="Rating" TYPE="RADIO"><FONT size="-1" FACE="HELVETICA, HELV, ARIAL">好材料 (4)</FONT></TD><TD><INPUT VALUE="3" NAME="Rating" TYPE="RADIO"><FONT size="-1" FACE="HELVETICA, HELV, ARIAL">一般;尚可 (3)</FONT></TD><TD><INPUT VALUE="2" NAME="Rating" TYPE="RADIO"><FONT size="-1" FACE="HELVETICA, HELV, ARIAL">需提高 (2)</FONT></TD><TD><INPUT VALUE="1" NAME="Rating" TYPE="RADIO"><FONT size="-1" FACE="HELVETICA, HELV, ARIAL">太差!(1)</FONT></TD>
</TR>
</TABLE>
<BR>
<FONT SIZE="-1" FACE="HELVETICA, HELV, ARIAL"><B>建议?</B></FONT>
<BR>
<TEXTAREA COLS="52" ROWS="3" WRAP="virtual" NAME="Comments"></TEXTAREA>
<BR>
<BR>
<INPUT VALUE="提交反馈意见" TYPE="SUBMIT">
</p>
</FORM>
</TD>
</TR>
</TABLE>
<br>
</font></td>
</tr>
</table>
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD background="../i/sw-gold.gif"><a border="0" href="index.html" onMouseOver="iOver('topmain'); iOver('bottommain'); self.status=mainblurb; return true;" onMouseOut="iOut('topmain'); iOut('bottommain'); self.status=''; return true;"><img alt="主菜单" border="0" src="../i/main.gif" name="bottommain"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topsection'); iOver('bottomsection'); self.status=sectionblurb; return true;" onMouseOut="iOut('topsection'); iOut('bottomsection'); self.status=''; return true;" href="index8.html"><img alt="章节菜单" border="0" src="../i/section.gif" name="bottomsection"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topfeedback'); iOver('bottomfeedback'); self.status=feedbackblurb; return true;" onMouseOut="iOut('topfeedback'); iOut('bottomfeedback'); self.status=''; return true;" href="j-customtags-7-3.html"><img alt="给出此教程的反馈意见" border="0" src="../i/feedback.gif" name="bottomfeedback"></a></TD><TD width="100%" background="../i/sw-gold.gif"><img src="../i/c.gif"></TD><TD background="../i/sw-gold.gif"><img border="0" src="../i/xprevious.gif"></TD><TD background="../i/sw-gold.gif"><img border="0" src="../i/xnext.gif"></TD>
</TR>
<TR>
<TD width="150" height="1" bgcolor="#000000" colspan="6"><IMG alt="" height="1" width="150" src="../i/c.gif"></TD>
</TR>
</TABLE>
<TABLE width="100%" cellpadding="0" cellspacing="0" border="0">
<TR>
<TD width="100%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><img alt="" height="1" width="1" src="../i/c.gif"></td>
</tr>
<tr valign="top">
<td class="bbg" height="21"> <a class="mainlink" href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/ibm/index.shtml">关于 IBM</a><span class="divider"> | </span><a class="mainlink" href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/ibm/privacy/index.shtml">隐私条约</a><span class="divider"> | </span><a class="mainlink" href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/ibm/legal/index.shtml">法律条款</a><span class="divider"> | </span><a class="mainlink" href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/ibm/contact/index.shtml">联系 IBM</a></td>
</tr>
</table>
</TD>
</TR>
</TABLE>
<script src="//www.ibm.com/common/stats/stats.js" language="JavaScript1.2" type="text/javascript"></script>
<noscript>
<img border="0" alt="" height="1" width="1" src="//stats.www.ibm.com/rc/images/uc.GIF?R=noscript"></noscript>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -