论坛首页 Web前端技术论坛

为什么JSP取不到EXT页面的请求参数?

浏览 1318 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2009-09-15  
EXT页面中的JS:
fp.getForm().submit({
    params: {
      tgmc: global_tgmc,
      ppdh: global_ppdh
    },
    url: 'DealPhoto.jsp',
    method : 'POST',
    waitMsg: 'Uploading your photo...',
    success: function(fp, o){
    	win.close();
    }
    failure: function(fp, o){
    	Ext.Msg.alert('<font size=4>提示</font>',o.result.msg);
    }
});

这样在JSP页面中用下面的代码取不到参数:
String tgmc = request.getParameter("tgmc");
String ppdh= request.getParameter("ppdh");
System.out.println("tgmc= "+tgmc);
System.out.println("ppdh= "+ppdh);

打印结果都为null,
但如果我在JS中不用params,把参数写在url中:
url: 'DealPhoto.jsp?ppdh='+global_ppdh+'&tgmc='+global_tgmc,

则可以取到参数。
或者:在JS中用params,将method改为'get',也可取到参数。
我的FormPanel如下:
	var fp = new Ext.FormPanel({
        //renderTo: 'hello-tabs',
		region: 'center',
        fileUpload: true,
        width: 500,
        frame: true,
        //title: 'File Upload Form',
        autoHeight: true,
        bodyStyle: 'padding: 10px 10px 0 10px;',
        labelWidth: 50,
        defaults: {
            anchor: '95%',
            allowBlank: false,
            msgTarget: 'side'
        },
        items: [{
            xtype: 'fileuploadfield',
            id: 'form-file',
            emptyText: 'Select an image',
            fieldLabel: 'Photo',
            name: 'photo-path',
            buttonText: '',
            buttonCfg: {
                iconCls: 'upload-icon'
            }
        }],
        buttons: [{
        	id: 'up',
            text: ' 上  传 ',
            handler: function(){
                if(fp.getForm().isValid()){
                	//alert("ppdh="+global_ppdh+"  tgmc="+global_tgmc);
                	Ext.getCmp("up").disable();
		fp.getForm().submit({
		//params: {
		//  tgmc: global_tgmc,
		//  ppdh: global_ppdh
		//},
		url: 'DealPhoto.jsp?ppdh='+global_ppdh+'&tgmc='+global_tgmc,
		method : 'POST',
		waitMsg: 'Uploading your photo...',
		success: function(fp, o){
		   Ext.Msg.alert('<font size=4>提示</font>','<font color=red>图片上传成功</font>!',callBack,this);
		   grid_DataStore2.reload();
		   win.close();
		},
                   failure: function(fp, o){
    	          Ext.Msg.alert('<font size=4>提示</font>',o.result.msg);
                   }
});
}
            }
        },{
            text: ' 重  置 ',
            handler: function(){
                fp.getForm().reset();
            }
        },{
            text: ' 关  闭 ',
            handler: function(){
                win.close();
            }
        }]
    })
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics