当前位置: 代码迷 >> Java Web开发 >> 请问 java.net.SocketTimeoutException: Read timed out
  详细解决方案

请问 java.net.SocketTimeoutException: Read timed out

热度:309   发布时间:2016-04-17 14:58:40.0
请教 java.net.SocketTimeoutException: Read timed out
上传文件代码bean
/**
  *   @author   lichuxiong
  */
package   arch.upload;

import   java.io.*;
import   java.util.Date;
import   javax.servlet.http.*;
import   javax.servlet.ServletException;
import   javax.servlet.http.HttpServletRequest;
import   javax.servlet.http.HttpServletResponse;
import   javax.servlet.http.HttpSession;
import   javax.servlet.ServletInputStream;


  public   class   UpFileThread   implements   Runnable{
 
  HttpServletRequest   request;
  HttpServletResponse   response;
  private   boolean   state;//线程是否已经启动
  private   boolean   running;//是否正在运行
  private   boolean   complete;//是否已经完成
  private   int   percent;  
 
  public   UpFileThread()   {
super();
state=false;
running=false;
complete=false;
percent=0;

}      
/**
  *   初始化时把页面的request和response传递进来
  *   @param   request
  *   @param   response
  */
public   UpFileThread(HttpServletRequest   request,HttpServletResponse   response)   {
super();
this.request=request;
this.response=response;
state=false;
running=false;
complete=false;
percent=0;
}    

public   void   setRequest(HttpServletRequest   request)   {
this.request   =   request;
}
public   void   setResponse(HttpServletResponse   response)   {
this.response   =   response;
}
public   synchronized   boolean   isComplete()   {
return   complete;
}
public   synchronized   void   setComplete(boolean   complete)   {
this.complete   =   complete;
}
public   synchronized   int   getPercent()   {
return   percent;
}
public   synchronized   void   setPercent(int   percent)   {
this.percent   =   percent;
}
public   synchronized   boolean   isRunning()   {
return   running;
}
public   synchronized   void   setRunning(boolean   running)   {
this.running   =   running;
this.setState(running);
}
public   synchronized   boolean   isState()   {
return   state;
}
public   synchronized   void   setState(boolean   state)   {
this.state   =   state;
}
/**
  *   判断能不能上传     后缀名,文件大小
  *   @param   suffix
  *   @param   size
  *   @return
  */
public   boolean   canUpload(String   suffix,int   size){
//System.out.println(suffix.toLowerCase());
//System.out.println(size);
Suffix   suf=new   SearchSuffix().getSuffixMember(suffix.toLowerCase());
if(suf!=null&&suf.getSize().intValue()> =size){
return   true;
}
return   false;
}
/**
  *   文件上传主要方法
  *   @throws   ServletException
  *   @throws   IOException
  */
public   synchronized   void   up()   throws   ServletException,   IOException{
  相关解决方案