开发者社区 问答 正文

struts2上传下载,下载非txt类型文档后台报错,但文件成功下载了 ?报错

下载非txt类型文档时后台报了个异常:(下载txt不报异常)
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:451)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:770)
请问怎么在下载其他非txt类型文件时不报错。谢谢。

我在downloadAction里是这样获取InputStream的:
public InputStream getDownLoadFile() throws Exception {
fileName = new String(fileName.getBytes("ISO8859-1"), "UTF-8");
return new FileInputStream(new File(path + fileName)); //path + fileName(绝对路径下的文件)
}

展开
收起
爱吃鱼的程序员 2020-06-24 13:21:33 551 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    我现在也遇到了这个问题同求。

    2020-06-24 13:21:48 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答地址:
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等