毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> WEB开发 >> 正文

Extjs的form传递参数问题

更新时间:2012-12-11:  来源:毕业论文

Extjs的form传递参数问题
Ext.onReady(function() {     var form = new Ext.form.FormPanel({         baseCls: 'x-plain',         labelWidth: 55,         url:'save-form.php',         defaultType: 'textfield',         items: [{             fieldLabel: '用户名',             name: 'username',             anchor:'100%'  // anchor width by percentage         },{             fieldLabel: '密码',             inputType: 'password',             name: 'password',             anchor: '100%'  // anchor width by percentage         },{                        xtype: 'radiogroup',             fieldLabel: '性别',             name:'gender',                       items: [                 {boxLabel: '男', name: 'rb-auto', inputValue: 1},                 {boxLabel: '女', name: 'rb-auto', inputValue: 2},                         ]                       }],            buttons: [{             text: '保存',             handler: function(){                                   Ext.Ajax.request({                        url : 'manage_add.action',                         params:{'username':'username','password':'password','gender':'gender'},                     method : 'post',                        success : function(response) {                         Ext.Msg.alert("提示", "方法调用成功");                                                 },                        failure : function() {                            Ext.Msg.alert("提示", "方法调用失败");                        }                    });                                 }         },{             text: '重置',             handler: function(){                 form.form.reset();             }                 }]     });


manage action的代码:

Java  package cn.feng.action;   import javax.annotation.Resource;   import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller;   import com.opensymphony.xwork2.ActionContext;   import cn.feng.bean.Employee; import cn.feng.service.EmployeeService;     @Controller @Scope("prototype") public class EmployeeManageAction {     @Resource EmployeeService employeeService;     private Employee employee;           public Employee getEmployee() {         return employee;     }     public void setEmployee(Employee employee) {         this.employee = employee;     }     public String addUI(){         return "add";     }     public String add(){         employeeService.save(employee);         ActionContext.getContext().put("message", "保存成功");         return "message";     } }
params:{'username':'username','password':'password','gender':'gender'},
这种参数传递,不可能封装到:action中的:employee中。
你试试打印employee的值。看看。

表单域的 name 用 employee.xxx 如名称 那么 名称文本框的name属性改为employee.username这样就能提交到后台action里employee对象里。所有提交的参数都可以在employee拿到。lz试试吧

params:{'username':'username','password':'password','gender':'gender'},

你的params参数有问题,这样不是传递输入项的值,而是传递下面描红的内容了'username','password':'password','gender':'gender'


JavaScript code? Ext.Ajax.request({                        url : 'manage_add.action',                         params:form.getForm().getValues() ,//获取表单输入的键值对                     method : 'post',                        success : function(response) {                         Ext.Msg.alert("提示", "方法调用成功");                                                 },                        failure : function() {                            Ext.Msg.alert("提示", "方法调用失败");                        }                    });  

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。