首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

getWriter() has already been called,该怎么解决

2012-04-05 
getWriter() has already been calledJava codepublic void doPost(HttpServletRequest request, HttpServ

getWriter() has already been called

Java code
public void doPost(HttpServletRequest request, HttpServletResponse response)            throws ServletException, IOException {        response.setContentType("text/html;charset=UTF-8");        PrintWriter out = response.getWriter();        out.print( " <script> alert( 'Booking successfully ') </script> ");        ByteArrayOutputStream out1 = QRCode.from(all).to(ImageType.PNG).stream();            response.setContentType("image/png");            response.setContentLength(out1.size());                       OutputStream outStream = response.getOutputStream();            outStream.write(out1.toByteArray());            outStream.flush();                                    outStream.close();

上網看過,只能用其中一個.但是我想用2個. 怎樣做. 另外,我試過加out.clear() 和out = pageContext.pushBody(); 就出錯.cannot find symbol.

[解决办法]
你是想显示图片吧。直接<img src="ImgServlet" />获取图片。也就是图片另外用个servlet。

热点排行