日期:2014-05-17  浏览次数:20721 次

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。