In struts, there is only one tag instance with one tag, so if there is one state field in tag class, please don't forget to revert the value of the state field before returning .
For example:
public class UserDefinedTableTag extends TagSupport
{
private boolean isAddRichScript = false;
public int doEndTag() throws JspException {
isAddRichScript = false;
return EVAL_PAGE;
}
private void addNote(UserDefinedTableColumnConfig userDefinedTableColumnConfig, StringBuffer outStr) {
if("T".equals(userDefinedTableColumnConfig.getRichHtml()))
{
if(!isAddRichScript)
{
isAddRichScript = true;
outStr.append(richScript);
}
outStr.append(richHtml);
}
}
}
JSP标签状态管理
本文介绍了一个自定义JSP标签的实现方式,着重讨论了如何正确管理标签的状态,特别是布尔类型的成员变量。通过实例展示了如何避免因状态管理不当而导致的问题。
1037

被折叠的 条评论
为什么被折叠?



