我有个formpanel, 里面有个FileUploadField,选择一个文件后,传到struts2的Action中,但是从调试的显示中看到参数没有传过去,响应的结果为null.
我想请大家帮我看看代码怎么改,多谢了
MyDesktop.ScriptWindow = Ext.extend(Ext.app.Module, {
id:'script-win',
init : function(){
this.launcher = {
text: 'Script Selection',
iconCls:'tabs',
handler : this.createWindow,
scope: this
}
},
createWindow : function(){
var desktop = this.app.getDesktop();
var win = desktop.getWindow('script-win');
if(!win){
win = desktop.createWindow({
id: 'script-win',
title:'Script Selection',
width:400,
height:450,
iconCls: 'tabs',
shim:false,
animCollapse:false,
border:false,
constrainHeader:true,
layout: 'fit',
items: new Ext.FormPanel({
id:'script',
labelWidth: 70,
frame:true,
bodyStyle:'padding:5px 5px 0',
width: 350,
items: [{
xtype:'fieldset',
title: 'Script Load',
collapsible: true,
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
items :[new Ext.ux.form.FileUploadField({
id: 'upload',
name: 'upload',
emptyText: '',
fieldLabel: 'Script',
allowBlank:false,
buttonText: '',
buttonCfg: {
iconCls: 'tabs'
}
}),
new Ext.form.ComboBox({
id: 'mobile',
name:'mobile',
triggerAction:'all',
fieldLabel: 'Phone',
store: store,
displayField: 'imsi',
valueField: 'ip',
mode:'local',
allowBlank:false,
emptyText: 'Select a phone'
})
],
buttons: [{
type: 'submit',
text: 'Associate',
handler:function(){
//Ext.Msg.alert("success", Ext.getCmp('upload').getValue());
if(Ext.getCmp('script').getForm().isValid()){
Ext.getCmp('script').getForm().doAction("submit",{
url:"scriptLoad.action",
method:"post",
success:function(form,action){
Ext.Msg.alert("Success",action.result.message);
},
failure:function(form, action){
Ext.Msg.alert("Failer",action.result.message);
}
})
}
}
},{
text: 'Cancel',
handler: function(){
Ext.getCmp('upload').reset();
Ext.getCmp('mobile').reset();
}
}]
},
{
xtype:'fieldset',
title: 'Script View',
collapsible: true,
height:250,
labelWidth: 2,
items : new Ext.form.TextArea({
xtype:'textarea',
name: 'script',
anchor: '100% 100%',
disabled: true,
value:'loop->1:100, CALL -> <TO_BE_DEFINED>:5, SLEEP -> 2000, END LOOP -> ID=1'
})
}]
})
});
}
win.show();
}
});
LoadScriptAction.java
public class LoadScriptAction extends ActionSupport{
private File upload;
private String uploadContentType;
private String uploadFileName;
private String mobile;
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getUploadContentType() {
return uploadContentType;
}
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
public String getUploadFileName() {
return uploadFileName;
}
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String execute() throws Exception{
message = this.uploadFileName + " " + this.mobile;
return SUCCESS;
}
}
<struts>
<include file="struts-default.xml"/>
<package name="script" extends="json-default">
<action name="scriptLoad" class="android.action.LoadScriptAction">
<result type="json"/>
</action>
</package>
</struts>
调试显示: (我要传两个参数过去,一个是我选择的文件,一个是mobile的号码。为什么这里只显示传了一个参数过去?)
参数application/x-www-form-urlencoded
|
|
mobile | 0610550020 |
源代码
|
|
mobile=0610550020 |
响应:
{"message":"null 0610550019","mobile":"0610550019","upload":null,"uploadContentType":null,"uploadFileName"
:null}