📄 simpletagdemo.java
字号:
/**
*
*/
package customtag;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.util.*;
import javax.servlet.jsp.*;
/**
* @author Administrator
*
*/
public class SimpleTagDemo extends SimpleTagSupport {
private int num;
public void setNum(int num) {
this.num = num;
}
/**
* Called by the container to invoke this tag.
*
* @throws JspException If an error occurred while processing this tag.
* @throws IOException If there was an error writing to the output
* stream.
* @todo Implement this javax.servlet.jsp.tagext.SimpleTag method
*/
public void doTag() throws JspException, IOException {
JspWriter out = this.getJspContext().getOut();
out.println("<h1>演示" + num + "次输出标签体的内容</h1>");
for (int i = 0; i < num; i++) {
getJspContext().setAttribute("count", String.valueOf(i + 1));
getJspBody().invoke(null);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -