Ext+struts2 上传文件信息

本文详细介绍了如何使用Ext.js框架创建一个用于文件上传的组件,并解释了关键配置选项的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//ext代码

var _fileForm = new Ext.FormPanel({

layout : "fit",

frame : true,

border : false,

autoHeight : true,

waitMsgTarget : true,

defaults : {

bodyStyle : 'padding:10px'

},

margins : '0 0 0 0',

labelAlign : "left",

labelWidth : 50,

fileUpload : true,

items : [{

xtype : 'fieldset',

title : '选择文件',

autoHeight : true,

items : [{

id : 'uploadFileId',

name : 'uploadFile', //该名称与Struts2中定义的文件名一致

xtype : "textfield",

fieldLabel : '文件',

inputType : 'file',

anchor : '96%'

}]



}]

});

//action代码

private File uploadFile;// 上传文件域对象 ,该名称一定要与上传文件类型的name一致,struts2自动会通过setter进行注入

// 上传文件名

private String uploadFileFileName; //在上传文件name+FileName就是上传文件名称,struts2自动注入

// 上传文件类型

private String uploadFileContentType;public File getUploadFile() {

return uploadFile;

}

public void setUploadFile(File uploadFile) {

this.uploadFile = uploadFile;

}

public String getUploadFileFileName() {

return uploadFileFileName;

}

public void setUploadFileFileName(String uploadFileFileName) {

this.uploadFileFileName = uploadFileFileName;

}

public String getUploadFileContentType() {

return uploadFileContentType;

}

public void setUploadFileContentType(String uploadFileContentType) {

this.uploadFileContentType = uploadFileContentType;

}

可以通过this.getter来获取上传的信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值