1.response.getWriter().print("");
2.PrintWriter out = response.getWriter();
out.print("");
out.close();
第一種方式可以嗎?流會自動關閉嗎?
2 回答

呼如林
TA貢獻1798條經驗 獲得超3個贊
response.getWriter().print("");不會自動關閉
response.getWriter源碼
public PrintWriter getWriter()
/* */ throws IOException
/* */ {
/* 213 */ PrintWriter writer = this.response.getWriter();
/* 214 */ if (isFinished()) {
/* 215 */ this.response.setSuspended(true);
/* */ }
/* 217 */ return writer;
/* */ }
print方法源碼
public void print(String s) {
if (s == null) {
s = "null";
}
write(s);
}
添加回答
舉報
0/150
提交
取消