【发布时间】:2014-02-21 17:35:56
【问题描述】:
我正在编写一个 JSTL 经典 Html 选择标签。该标签有一个用于构建标签的大项目(列表)。以下是我的代码:
public class MyBigSelectTag extends TagSupport {
private static final long serialVersionUID = 1L;
protected List<SelectItem> bigItems;
@Override
public void release() {
// Release bigItems when the tag is releasing.
this.bigItems = null;
}
@Override
public int doEndTag() throws JspException {
JspWriter out = this.pageContext.getOut();
try {
out.write("<select>");
for (SelectItem option : bigItems) {
out.write("<option />");
}
out.write("</select>");
} catch (IOException ex) {
throw new JspTagException(ex.getMessage(), ex);
} finally {
// Do I have to set null to bigItems Here because it is too big?
this.bigItems = null;
}
return super.doEndTag();
}
public void setBigItems(List<SelectItem> bigItems) {
this.bigItems = bigItems;
}
}
我的问题是:我是否必须在 FINALLY 块中将 bigItems 属性设置为 NULL,因为 bigItems 太大了?请注意,我已经在 'release' 函数中将此属性设置为 null。
有人知道吗?非常感谢!
【问题讨论】:
标签: java jsp jakarta-ee memory-leaks jstl