Wicket 1.5中的WebResponse.getOutputStream()?

Wicket 1.5中的WebResponse.getOutputStream()?,wicket,wicket-1.5,Wicket,Wicket 1.5,此代码在1.4中适用于我: WebResponse response = (org.apache.wicket.request.http.WebResponse) getResponse(); response.setAttachmentHeader("List.xls"); response.setContentType("application/ms-excel"); OutputStream out = response.getOutputStream(); WritableWorkboo

此代码在1.4中适用于我:

WebResponse response = (org.apache.wicket.request.http.WebResponse) getResponse();
response.setAttachmentHeader("List.xls");
response.setContentType("application/ms-excel");
OutputStream out = response.getOutputStream();
WritableWorkbook workbook = Workbook.createWorkbook(out);
.....
.....
workbook.write();
workbook.close();
我在1.5中看到没有WebResponse.getOutputStream()-但它没有被标记为不推荐

我已经阅读了1.5版迁移指南,但没有看到任何明显的解决方案


有人能告诉我在1.5中应该怎么做吗。

这个问题昨天已经解决了。将成为Wicket 1.5.4的一部分。
但是对于这个用例,您应该使用一个资源。请参阅ResourceLink的实现。

您可以将
响应
包装在
输出流中

public final class ResponseOutputStream extends OutputStream {
    private final Response response;
    private final byte[] singleByteBuffer = new byte[1];
    public ResponseOutputStream(Response response) {
        this.response = response;
    }
    @Override
    public void write(int b) throws IOException {
        singleByteBuffer[0] = (byte) b;
        write(singleByteBuffer);
    }
    @Override
    public void write(byte[] b) throws IOException {
        response.write(b);
    }
    @Override
    public void write(byte[] b, int off, int len) throws IOException {
        if (off == 0 && len == b.length) {
            this.write(b);
        } else {
            super.write(b, off, len);
        }
    }
}

我正在使用jExcelAPI库。我需要将OutputStream作为参数提供给工作簿。createWorkbook我没有将输出写入磁盘-要将其直接流式传输到浏览器。你的建议对这个有用吗?是的,它会-你使用ResourceLink来保存资源,例如AbstractResource。谢谢,我会试试这个。我现在还不能测试。