我是eclipse和tomcat的新手。我正在创建一个servlet来获取图像并将其保存在数据库中 我使用的是Jre 1.6和tomcat 7.为此,我使用了自定义库:
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
现在我在部署项目时出现此错误:
10 Jun, 2013 6:34:37 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/BIOMetric2]]
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
etc..
答案 0 :(得分:-1)
我使用了@MultipartConfig,现在工作正常。我用过这段代码。 ...
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
...
Part filePart = request.getPart("img");
String imageName = filePart.getName();
InputStream in = filePart.getInputStream();
...