开发者社区> 问答> 正文

JFinal renderFile() 下载pdf类型文件jetty会报错?报错

@JFinal 你好,想跟你请教个问题:

当renderFile的文件是pdf类型的时候jetty会报错,而其他类型文件没有问题,算bug吗?

org.eclipse.jetty.io.EofException
	at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:914)
	at org.eclipse.jetty.server.AbstractHttpConnection.flushResponse(AbstractHttpConnection.java:651)
	at org.eclipse.jetty.server.AbstractHttpConnection$Output.close(AbstractHttpConnection.java:1063)
	at com.jfinal.render.FileRender.render(FileRender.java:110)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:92)
	at com.jfinal.plugin.druid.DruidStatViewHandler.handle(DruidStatViewHandler.java:74)
	at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:47)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:365)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Thread.java:724)
Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
	at sun.nio.ch.SocketDispatcher.write0(Native Method)
	at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
	at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:94)
	at sun.nio.ch.IOUtil.write(IOUtil.java:51)
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:466)
	at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:293)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:362)
	at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:850)
	... 38 more

 

展开
收起
爱吃鱼的程序员 2020-06-22 14:53:38 802 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    估计是文件体积太大的原因吧

    IE下tomcat也会报ClientAbortException

    <preclass="brush:java;toolbar:true;auto-links:false;">outputStream=response.getOutputStream();byte[]buffer=newbyte[1024];for(intn=-1;(n=inputStream.read(buffer))!=-1;){outputStream.write(buffer,0,n);}outputStream.flush();

    当用户点击下载文件链接后,再点取消就会报错,无法捕获到这个IOException

    <preclass="brush:java;toolbar:true;auto-links:false;">byte[]buffer=newbyte[inputStream.available()];inputStream.read(buffer);

    改成一次性读写,遇到大文件可能会出问题,不过可以暂时解决一下。

    2020-06-22 14:53:57
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Apache Flink-重新定义计算》PDF下载 立即下载
《Visual Edge Computing Service视图计算产品发布介绍》PDF 立即下载
15分钟打造你自己的小程序 立即下载

相关实验场景

更多