序列化前端后台

前端:(注意:input框: 不能获取disabled的值,可用readonly来代替; 复选框:没勾选不可获取值)

var biaotou_ = JQuery('#biaotou').serializeObject() ;  
var biaotou = JSON.stringify(biaotou_) ;   

JQuery.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    JQuery.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

后台

String biaotou = request.getParameter("biaotou");
biaotou = "["+biaotou+"]";

List<??Vo> listH = JSONArray.parseArray(biaotou, ??Vo.class);
发布了80 篇原创文章 · 获赞 0 · 访问量 672

猜你喜欢

转载自blog.csdn.net/weixin_42699486/article/details/88849108
今日推荐