热门文章 | 热门软件| 热门源码 | 热门电影 | 知识库 | 联系我们
软件 源码 教程 影视 健康 招聘
  HTML | JavaScript | ASP | PHP | JSP | NET | VB | VC | VF | Windows | Linux | Mysql | Mssql | Oracle | Struts 
当前位置: 创世纪计算机资源网 -> 文章频道 ->struts 
站内搜索:
使用spring MVC框架进行文件上传(2)
作者:luna8418 来源:blog 整理日期:2007-3-13

<--------------------------控制类------------------------->
<---------------------定义commandClass-------------------->
public class FileUploadBean {

    private byte[] file;

    public void setFile(byte[] file) {
        this.file = file;
    }

    public byte[] getFile() {
        return file;
    }

}
<---------------------定义commandClass-------------------->
4:定义一个form表单index.jsp
<form method="post" action="upload.htm" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit"/>
5:定义confirmation.jsp及fail.jsp
confirmation.jsp如下:
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
successView
</title>
</head>
<body bgcolor="#ffffff">
<h1>
Upload Successful
</h1>
</body>
</html>

fail.jsp如下:
<html>
<head>
<title>Upload a file please</title>
</head>
<body>
<h1>no file,Please upload a file</h1>
<form method="post" action="uploadfile.htm" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit"/>
</form>
</body>
</html>
6:运行tomcat。
预览 ie里面:http://localhost/springmvc/index.jsp
注:
a:文件目录为tomcat-HOME/webapps/springmvc/
.jsp文件都放在根目录下,.class文件放在/WEB-INF/classes/中

其他文件放在/WEB-INF/里面。
b:如果连上面的你都有疑问,那还是去看看spring的基础知识吧。

 

[1]  [2]  
相关文章