当前页面: 开发资料首页 → JSP 专题 → [求助]在Bean中输出html问题(我找到方法了,不过出了点问题)
[求助]在Bean中输出html问题(我找到方法了,不过出了点问题)
摘要: [求助]在Bean中输出html问题(我找到方法了,不过出了点问题)
这个问题在网上找到了如下解决方法:
jsp:useBean id="bean" class="XXX" scope="XXX"/>
<%
bean.setOut(out);
bean.test();
%>
bean里面部分代码
import javax.servlet.jsp.*;
JspWriter out= null;
public void setOut( JspWriter out)
{
this.out=out;
}
public void test()
{
out.println("
hello");
}
但我的eclipse开发工具指出out.println那行有"Unhandled exception type IOException"错误,
为什么我这不行啊,还是哪里出错了呢?
public void test()
{
try{
out.println("
hello");
}catch(IOException e){
System.out.prinln(e);
}
}
未经处理的IOException异常类型
回避或捕获这个异常就OK了