📄 filtertag.java
字号:
package custom;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class filterTag extends BodyTagSupport
{
public int doStartTag()
{
return EVAL_BODY_BUFFERED;
}
public int doAfterBody() throws JspException
{
String cleanString = "";
BodyContent bc = getBodyContent();
// Get bc as a string
String unfiltered = bc.getString();
// StringTokenizer splits the string into tokens, using spaces as the
// delimiters
StringTokenizer st = new StringTokenizer(unfiltered);
while (st.hasMoreTokens())
{
String temp = st.nextToken();
// Censor if we find the dreaded word
if(temp.equalsIgnoreCase("drat"))
temp = "****";
// Add a space between each word
cleanString += " " + temp;
}
try
{
getPreviousOut().print(cleanString);
}
catch(Exception e)
{
throw new JspException(e.toString());
}
return SKIP_BODY;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -