日期:2014-05-17  浏览次数:20824 次

sruts2上传问题。看的是浪曦的视频
刚接触这个。不怎么会玩。求各位指教下,我按照视频的步骤做下来。结果缓存没有我上传的文件

严重:   Servlet.service()   for   servlet   default   threw   exception
java.io.FileNotFoundException:   F:\soft\tomcat6\work\Catalina\localhost\struts2Dome\upload__418edaad_13311433555__8000_00000002.tmp   (系统找不到指定的文件。)
at   java.io.FileInputStream.open(Native   Method)
at   java.io.FileInputStream. <init> (FileInputStream.java:106)
at   com.action.LoginAction.findUser(LoginAction.java:34)
at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native   Method)
at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at   java.lang.reflect.Method.invoke(Method.java:597)
at   com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at   com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at   com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at   com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at   com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at   com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at   com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)


错误提示太多了超一万字了。。。。


action

[code=Java]package   com.action;

import   java.io.File;
import   java.io.FileInputStream;
import   java.io.FileOutputStream;
import   java.io.InputStream;
import   java.io.*;


import   org.apache.struts2.ServletActionContext;

import   dao.UserDao;

import   vo.Users;

public   class   LoginAction{

private   Users   users;
private   String   username;
private   String   password;
private   File   file;
private   String   fileFileName;
private   String   fileContuenType;



public   String   findUser()   throws   Exception   {
UserDao   userDao   =   new   UserDao();
String   judge   =   userDao.findUsers(users.getUsername(),   users.getPwd());
if   (null   !=   judge)   {

System.out.println(file);
InputStream   is   =   new   FileInputStream(file);//接收文件输入流

String   root   =   ServletActionContext.getRequest().getRealPath( "/ ");

File   destFile   =   new   File(root,this.getFileFileName());//保存文件存放路径

OutputStream   so   =   new   FileOutputStream(destFile);//文件输出

byte[]   buffer   =   new   byte[1024];
int   lengt   =0;
while((lengt=is.read(buffer))> 0){
so.write(buffer);
}
is.close();
so.close();





return   "success ";
}   else   {
return   "errors &q