JSP中的Simple自定义标签使用
来源:互联网 发布:农村淘宝现状分析 编辑:程序博客网 时间:2024/05/18 03:02
Simple自定义标签使用
今天我们主要讲一下我们的simple这个自定义标签的使用!首先我们看一下simple这个是怎么使用的。
我们先看一下java类,首先java类要继承SimpleTagSupport类。
第一个实例:我们是输出那个自定义标签的内容。
我们重写doTag方法 这样写JspFragment jf=this.getJspBody();我们就获取到了jf这个被容的对象,然后我们用jf.invoke(null);就能输出了,这里的null不是输出是空的。
第二个实例:获取属性
在对应的类中写到的属性名称要和你在自定义方法中定义的一样。而且我们还得写一个setter方法。一定要按正确的格式。下面给一个例子 是一个count的例子 <tag>
<description>display user ip</description>
<name>Demo8</name>
<tag-class>com.web.tag.Demo8</tag-class>
<body-content>scriptless</body-content>
<attribute>
<name>count</name>
<required>yes</required>
<rtexprvalue>yes</rtexprvalue>
</attribute>
</tag>
public class Demo8 extends SimpleTagSupport{
privateint count;
publicvoid setCount(int count) {
this.count= count;
}
@Override
publicvoid doTag() throws JspException, IOException {
JspFragmentjf=this.getJspBody();
for(int i = 0; i < count; i++) {
jf.invoke(null);
}
}
<hbsi:Demo8count="5" >
This is my JSP page. <br>
</hbsi:Demo8>
这就是重复5次 如果在多name我们更改就行了
实例三:大小写转换
<hbsi:Demo9>
This is my JSP page. <br>
</hbsi:Demo9>
publicvoid doTag() throws JspException, IOException {
JspFragmentjf=this.getJspBody();
StringWritersw=new StringWriter();
jf.invoke(sw);
Stringcontent=sw.toString().toUpperCase();
JspWriterjw=this.getJspContext().getOut();
jw.write(content);
}
这就变成了大写的了
- JSP中的Simple自定义标签使用
- jsp中的自定义标签的使用
- Jsp中的自定义标签
- JSP中的自定义标签
- JSP中的自定义标签
- JSP自定义标签使用
- 使用 JSP自定义标签
- JSP页面中的自定义标签
- JSP页面中的自定义标签
- 如何自定义jsp中的标签
- JSP页面中的EL自定义标签及使用
- 自定义JSP中的Taglib标签之五自定义标签之SimpleTagSupport使用
- 自定义JSP中的Taglib标签之五自定义标签之SimpleTagSupport使用
- Jsp自定义标签使用笔记
- 如何使用jsp自定义标签
- 使用自定义的jsp标签
- jsp自定义标签新手使用
- jsp自定义标签的使用
- 软考进行时
- ubuntu比较稳妥的升级到11.10
- C语言小函数-栈
- 查看ubuntu版本号
- 美国或加拿大课程
- JSP中的Simple自定义标签使用
- 电信、联通一句话回应发改委反垄断调查
- Ext.Net 1.x_Ext.Net.CompositeField 综合布局
- JAVA高级应用学习笔记----流
- u盘知识
- 【工具箱】解题报告
- POJ 2752 KMP算法中next数组的应用
- utc
- 链表