本人通过struts2上传到tomcat服务器文件打不开,查看时发现比源文件小了,
这是个什么情况,有木有知道的?
这是个什么情况,有木有知道的?
解决方案 »
- IBM WebSphere Integratioin Developer在cvs上无法比对java类代码
- Hibernate的问题
- weblogic报错
- SQL里这么写:SELECT Title, 0 AS Filesortid ,HQL里该怎么写?注:Filesortid是表里边不存在的列。
- 思路:请教开发B/S结构的办公OA系统的开发架构?
- HIBERNATE如何实现论坛形式的分页,求源码,感激不尽
- web service 中传一个简单对象 简单对象里包含一个二维数组?
- 请问EJB的一些问题
- 谁能帮我看看这个Applet程序那里出错了?
- weblogic7部署ejb请教(新手问题)
- spring配置List属性的值
- 用filter过滤struts2的,在每个action中都加上事物代码。
private int id;
private String title;
private String context;
private File file;//与jsp表单中的名称对应
private String fileFileName;//FileName为固定格式
private String fileContentType;//ContentType为因定格式
//getter,setter方法省略//获取上传文件名,并将文件上传到服务器中
public String getFilename(){
System.out.println(fileFileName);
String root=ServletActionContext.getServletContext().getRealPath("/upload");
File desfile=new File(root,fileFileName);//文件上传到服务器上,在eclipse目录上查看不到
//File desfile=new File("E:\\JAVA\\JAVA学习\\单元项目",this.getFileFileName());
FileUtils.copyfile(file, desfile);
return fileFileName;
}//这是我自己编写的copyfile类.没有调用commons-fileupload包里的类.
public class FileUtils {
private static BufferedReader br=null;
private static BufferedWriter bw=null;
public static void copyfile(File sourcefile,File desfile)
{
try {
br=new BufferedReader(new InputStreamReader(new FileInputStream(sourcefile)));
bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(desfile)));
String str=null;
while((str=br.readLine())!=null){
bw.write(str);
}
bw.flush();
bw.close();
br.close();
} catch (FileNotFoundException e1) {
System.out.println("找不到文件");
e1.printStackTrace();
}
catch (IOException e) {
System.out.println("文件复制失败");
e.printStackTrace();
}
}
}表示层应该没有问题,你帮我看一下吧
我很鄙视,所以从来不用