0
我尝试编写关于自定义标签的演示,但这个问题..我讨厌它,我可以通过我自己来解决它。为什么在customtag中的pagecontext导致空异常
这里是我的.TLD文件:
<tag>
<name>custom</name>
<tagclass>MyTag.CustomerTag</tagclass>
<bodycontent>empty</bodycontent>
</tag>
这里是我的课CustomerTag:
public class CustomerTag extends TagSupport {
private PageContext _pageContext;
@Override
public int doStartTag() throws JspException {
try {
_pageContext.getOut().println("kakaka"); <-- **here cause exception**
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
return SKIP_BODY;
}
@Override
public int doEndTag() throws JspException {
return SKIP_PAGE;
}
}
这里是我的JSP文件:
<%@taglib uri="/WEB-INF/Marko.tld" prefix="myTag" %>
<myTag:custom />
请帮助我,谢谢所有人
是的,我通过删除decraling _pagecontext来解决它,它已经在我的课堂上了。非常感谢 :) – famfamfam