求struts+fileupload 上传实例???---高分,不够再加 求struts+fileupload 上传实例:最好能包括:前台页面,后台Action等的实现 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 网上很多 不过我是自己写的 也很方便下面是DONWLOAD的ACTIONpackage asatapp;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.actions.DownloadAction;public class CommonDownloadAction extends DownloadAction { protected synchronized StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Download a "jpeg" file - gets the file name from the // Action Mapping's parameter String contentType = "application/x-msdownload"; String path = mapping.getParameter(); response.setHeader("Content-Disposition","attachment; filename=\"" + path + "\""); ServletContext application = servlet.getServletContext(); return new ResourceStreamInfo(contentType, application, path); }} 前台用<html:file property="file"/>选择文件后台获得文件UploadFileForm uploadFileForm = null; if (form != null) { uploadFileForm = (UploadFileForm) form; } FormFile file = uploadFileForm.getFile();然后处理文件就行了UploadFileForm中定义一个属性FormFile file 搜狗面试题 请教:Map复制时出现一个Swingutilities2错误? 时间转换的问题 JAVA如何获取Socket绑定的设备名称 请问如何用java操作.dbf数据库?如:如何创建连接、插入数据到.dbf中? java 使用registry-3.1.3读取注册表 字符串中文的乱码问题?不知道如何解决 如何在jsp页面实现文件的上传和下载 ? 求助:java中哪个类能获得当前计算机名 hashtable问题!急! 如何设系统环境变量和用户环境变量 如何调用字体对话框的类???? 线程问题.请各位高手帮忙啊~~~~~~~
下面是DONWLOAD的ACTION
package asatapp;import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DownloadAction;public class CommonDownloadAction extends DownloadAction { protected synchronized StreamInfo getStreamInfo(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception { // Download a "jpeg" file - gets the file name from the
// Action Mapping's parameter
String contentType = "application/x-msdownload";
String path = mapping.getParameter();
response.setHeader("Content-Disposition","attachment; filename=\"" + path + "\"");
ServletContext application = servlet.getServletContext(); return new ResourceStreamInfo(contentType, application, path); }}
后台获得文件
UploadFileForm uploadFileForm = null;
if (form != null) {
uploadFileForm = (UploadFileForm) form;
} FormFile file = uploadFileForm.getFile();
然后处理文件就行了
UploadFileForm中定义一个属性FormFile file