long875938018 2010-07-28 17:57
浏览 182
已采纳

ext+struts2 跳转方法的问题。。

我初学ext看到前辈们写的一个方法是document.location = “bookList!export2Excel”
这样能跳转到bookList里面的export2Excel方法。我也一样写了这个方法。
他就跳转到struts.xml里面的input的页面。很奇怪。。我不知道问题出在那里。求前辈们解答。
还有遇到一个问题是,
我在后台把添加和修改写在一起。
所以我用一个事件
//修改信息
harListgrid.on('rowclick',function(harListgrid,rowIndex,event){
var record = harListgrid.getStore().getAt(rowIndex);
harInfoForm.getForm().loadRecord(record);
harInfoForm.buttons[0].setText('修改');
harInfoForm.buttons[1].setText('取消');

    harInfoForm.buttons[1].setHandler(function(){
         harInfoForm.buttons[0].setText('添加');
         harInfoForm.getForm().reset();
         harInfoForm.buttons[1].setText('重置');
    });

});

把添加的字样给改了。。添加的方法是这样:

harInfoForm.getForm().doAction('submit',{
url:'/liuycTest3/addOrUpdate.action',
method:'post',
params:'',
success:function(form,action){
if(action.result.msg == 'add'){
Ext.Msg.alert('消息',"添加成功!!");

                        }else if(action.result.msg == 'update'){
                            Ext.Msg.alert('消息'," 修改成功!!");
                            harInfoForm.buttons[0].setText('添加');
                        }
                        harInfoForm.getForm().reset();
                        document.location = 'harInfoList.jsp';
                    },
                    failure:function(){
                        Ext.Msg.alert("提示","操作有误!!");
                    }
                 });

很奇怪的是添加可以添加。
但是一到修改就直接到failure这边了。。
昨天一前辈帮我用ajax不传递参数能进入到action
后来回家我自己在改成这样:
if(this.text=='修改'){
getHarInfoStore();
Ext.Ajax.request({
url:'addOrUpdate.action',
params:{
id:harId,
parId:parId,
code:code,
brand:brand,
model:model
},
success:function(){

                 }
             })
         }else{
           harInfoForm.getForm().doAction('submit',{
                    url:'/liuycTest3/addOrUpdate.action',
                    method:'post',
                    params:'',
                    success:function(form,action){
                        if(action.result.msg == 'add'){
                             Ext.Msg.alert('消息',"添加成功!!");

                        }else if(action.result.msg == 'update'){
                            Ext.Msg.alert('消息'," 修改成功!!");
                            harInfoForm.buttons[0].setText('添加');
                        }
                        harInfoForm.getForm().reset();
                        document.location = 'harInfoList.jsp';
                    },
                    failure:function(){
                        Ext.Msg.alert("提示","操作有误!!");
                    }
                 });
         }
         }
});

还是能添加,但是到修改依然挂掉。。。求解!!!!
我只有三十分。全给了。求解!!!

  • 写回答

2条回答 默认 最新

  • fireinjava 2010-08-06 21:28
    关注

    ajax不传递参数能进入到action,可能是你的参数类型不匹配被Struts拦截了

    id:harId,
    parId:parId,
    code:code,
    brand:brand,
    model:model

    这几个值可以alert()出来看下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算