|
本帖最后由 jeecgadmin 于 2016-2-1 11:13 编辑
Exception in thread "http-apr-8080-exec-7"
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at java.util.zip.GZIPOutputStream.finish(GZIPOutputStream.java:169)
at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:238)
at org.jeecgframework.core.aop.GZipFilter.gzip(GZipFilter.java:120)
at org.jeecgframework.core.aop.GZipFilter.doFilter(GZipFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:119)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2522)
------代码如下:
public HttpServletResponse doviewOrDownloadFile(UploadFileWdgl uploadFile,ReflectHelper reflectHelper) {
uploadFile.getResponse().setContentType("UTF-8");
uploadFile.getResponse().setCharacterEncoding("UTF-8");
InputStream bis = null;
BufferedOutputStream bos = null;
HttpServletResponse response = uploadFile.getResponse();
HttpServletRequest request = uploadFile.getRequest();
long fileLength = 0;
String downLoadPath = "";
String videoType = "mp4,wmv,avi,rmvb,rm,mts";
if(videoType.contains(uploadFile.getExtend())){
String rootPath = ResourceUtil.getConfigByName("file_home");
String videoPath = ResourceUtil.getConfigByName("video_home");
downLoadPath = rootPath +"/"+ videoPath + uploadFile.getRealPath();
if (uploadFile.getRealPath() != null && uploadFile.getContent() == null) {
fileLength = new File(downLoadPath).length();
try {
if(fileLength == 0)return response;
bis = new BufferedInputStream(new FileInputStream(downLoadPath));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
try {
if (!uploadFile.isView() && uploadFile.getExtend() != null) {
if (uploadFile.getExtend().equals("text")) {
response.setContentType("text/plain;");
} else if (uploadFile.getExtend().equals("doc")) {
response.setContentType("application/msword;");
} else if (uploadFile.getExtend().equals("xls")) {
response.setContentType("application/ms-excel;");
} else if (uploadFile.getExtend().equals("pdf")) {
response.setContentType("application/pdf;");
} else if (uploadFile.getExtend().equals("jpg") || uploadFile.getExtend().equals("jpeg")) {
response.setContentType("image/jpeg;");
} else {
response.setContentType("application/x-msdownload;");
}
response.setHeader("Content-disposition", "attachment; filename=" + new String((uploadFile.getTitleField() + "." + uploadFile.getExtend()).getBytes("GBK"), "ISO8859-1"));
response.setHeader("Content-Length", String.valueOf(fileLength));
}
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bis != null) {
bis.close();
}
if (bos != null) {
bos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return response;
}
|
|