zoukankan      html  css  js  c++  java
  • Jsp Tag

    package tags;
    
    import java.util.Collection;
    import java.util.Iterator;
    
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.tagext.TagSupport;
    
    public class IteratorTag extends TagSupport {
    
    	private String var;
    	private Collection items;
    	private Iterator iter;
    	
    	public String getVar() {
    		return var;
    	}
    
    	public void setVar(String var) {
    		this.var = var;
    	}
    
    	public Collection getItems() {
    		return items;
    	}
    
    	public void setItems(Collection items) {
    		this.items = items;
    	}
    
    	@Override
    	public int doStartTag() throws JspException {
    		iter=items.iterator();
    		if(iter.hasNext()){
    			this.pageContext.setAttribute(var, iter.next());
    			return this.EVAL_BODY_INCLUDE;
    		}
    		return this.SKIP_BODY;
    	}
    
    	@Override
    	public int doAfterBody() throws JspException {
    		if(iter.hasNext()){
    			this.pageContext.setAttribute(var, iter.next());
    			return this.EVAL_BODY_AGAIN;
    		}
    		return this.SKIP_BODY;
    	}
    }
    
    

    <?xml version="1.0" encoding="UTF-8"?>
    <!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>custom_dt</short-name>
    	<uri>/myCustomTags</uri>
    	<display-name>我的自定义</display-name>
    	<description>这是我的自定义标签,用于测试</description>
    
    	<tag>
    		<name>MyIteratorTag</name>
    		<tag-class>tags.IteratorTag</tag-class>
    		<body-content>JSP</body-content>
    		<display-name>测试的</display-name>
    		<description>自定义的迭代标签</description>
    		<attribute>
    			<name>var</name>
    			<required>true</required>
    			<rtexprvalue>false</rtexprvalue>
    			<description>变量名</description>
    		</attribute>
    		<attribute>
    			<name>items</name>
    			<required>true</required>
    			<rtexprvalue>true</rtexprvalue>
    			<description>用于iterate的集合</description>
    		</attribute>
    	</tag>
    </taglib>
    
    

  • 相关阅读:
    问题——虚拟机连接,查本地DNS,查软件位置,payload生成,检测注册表变化
    nmap命令解释
    SMB扫描,SMTP扫描
    操作系统识别,SNMP扫描
    服务扫描——查询banner信息,服务识别
    nmap之扫描端口(附加hping3隐藏扫描)
    scapy简单用法——四层发现
    转载 界面组装器模式
    设计模式=外观模式
    如何进行自动化测试和手工测试
  • 原文地址:https://www.cnblogs.com/wucg/p/1876615.html
Copyright © 2011-2022 走看看