jquery.param.patch.zip
页面上jQuery需要把一个复杂类型的javascript数组对象作为参数传到Struts2 action,但是他们的默认格式不匹配导致action无法正确获得参数。 Struts2 action class SomeAction{ List list; //getter setter //execute() } class SomeBean{ int id; //getter setter }参数为以下格式(OGNL格式)时,Struts2 action能正确映射list[0].id=1但是当jQuery发送ajax call的时候$.post(url, {list: [{id: 1}]})参数会被序列化为list[0][id]=1要转换成功,要么把jQuery的序列化格式改掉来迎合Struts2,要么给Struts2 action写个converter来迎合jQuery,前者更简单。于是Jquery-1.4.4.js line6134代码//buildParams( prefix + "[" + k + "]", v, traditional, add ); buildParams( prefix + "." + k, v, traditional, add );改jQuery源码并不是个好做法,最好是做个patch把$.param()覆盖掉.
1.17KB
文件大小:
评论区