为什么在360兼容模式下通过nutz下载文件是会提交多次,且会报错。而firefox 及chrome都不会。
但通过原始的servlet下载,虽然会提交多次,但不会报错。
有什么办法解决?
我也一样,这种情况在spring当中也一样会出现。
2016-01-23 10:26:52,477 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN - Error@/user/dfile :
ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:413)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:438)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:426)
点击下载的时候会运行一次,然后弹出下载框的时候会运行一下,点下载又会运行一次。
弹出下载框的时候会将输出流切断,所以报错了。不知道NUTZ怎么解决(spring似乎返回null就可以解决)
代码:
@At
@Ok("raw")
public InputStream dfile(HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("----begin upload2---");
response.setContentType("application/zip;charset=UTF-8");
response.addHeader("Content-disposition", "attachment; filename="
+ "1.ZIP");
InputStream in = null;
in = new FileInputStream(new File("g:/1.ZIP"));
return in ;
}
还是一样。
@At
@Ok("void")
public void dfile(HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.setContentType("application/zip;charset=UTF-8");
response.addHeader("Content-disposition", "attachment; filename="
+ "1.ZIP");
InputStream in = null;
in = new FileInputStream(new File("g:/1.ZIP"));
Streams.writeAndClose(response.getOutputStream(), in);
}
@wendal 是这样的