JSLT自定义标签
来源:互联网 发布:葡萄牙帝国知乎 编辑:程序博客网 时间:2024/05/21 14:05
http://java.sun.com/developer/technicalArticles/xml/WebAppDev3/index.html
1 tld文件的写法
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems,Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<!-- a tag library descriptor -->
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>first</shortname>
<uri></uri>
<info>A simple tab library for the examples</info>
<tag>
<name>helloparam</name>
<tagclass>mytags.HelloTagParam</tagclass>
<bodycontent>empty</bodycontent>
<info>Tag with Parameter</info>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>pwd</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems,Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<!-- a tag library descriptor -->
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>first</shortname>
<uri></uri>
<info>A simple tab library for the examples</info>
<tag>
<name>helloparam</name>
<tagclass>mytags.HelloTagParam</tagclass>
<bodycontent>empty</bodycontent>
<info>Tag with Parameter</info>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>pwd</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>
2 标签处理类的写法
package mytags;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class HelloTagParam extends TagSupport ...{
private String name;
private String pwd;
public void setName(String name) ...{
this.name = name;
}
public void setPwd(String pwd) ...{
this.pwd = pwd;
}
public int doStartTag() throws JspException ...{
try ...{
pageContext.getOut().print("Welcome, " +name+" "+pwd);
} catch (IOException ioe) ...{
throw new JspException("Error: IOException while writing to client");
}
return SKIP_BODY;
}
public int doEndTag() throws JspException ...{
return SKIP_PAGE;
}
}
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class HelloTagParam extends TagSupport ...{
private String name;
private String pwd;
public void setName(String name) ...{
this.name = name;
}
public void setPwd(String pwd) ...{
this.pwd = pwd;
}
public int doStartTag() throws JspException ...{
try ...{
pageContext.getOut().print("Welcome, " +name+" "+pwd);
} catch (IOException ioe) ...{
throw new JspException("Error: IOException while writing to client");
}
return SKIP_BODY;
}
public int doEndTag() throws JspException ...{
return SKIP_PAGE;
}
}
3 在JSP页面上的应用
<%...@ taglib uri="/WEB-INF/taglib.tld" prefix="first" %>
<first:helloparam name="中国人" pwd="1984"/>
<first:helloparam name="中国人" pwd="1984"/>
- JSLT 自定义标签
- JSLT自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 自定义标签
- 关于exe形式编程的一点心得
- Eclipse Birt的分页显示报表
- Eclipse Birt改变数据行背景颜色
- 开源的BUG管理系统,易于安装!
- 经典的javascript代码[自适应框架和html参数传递]
- JSLT自定义标签
- vb.net动态控件数组
- 设置401并取得用户名密码(base64解密)
- XSQL学习地址
- WINCE注册表编辑器
- 分页的sql代码
- 涂鸦
- 逆规范化数据列表
- 利用TBatchMove控件将数据导入MySQL数据库