乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      JQuery以對象提交Form到Spring MVC的方法

       KyunraWang 2017-09-07
      JQuery用POST方式直接將Form的數(shù)據(jù)提交給Spring MVC的方法,最大的坑就是原生類型(long,int)必須要有值,否則就出錯(cuò)。

      實(shí)體類(注意有原生類型)
      public class OltInfo {

        long id;
        String oltSN;
      ……
        int cards;
        int pons;
      ……

      提交的JS:
      $(function() {
        var s = $("#submitId");
        $("#submitId").click(function() {
          $.ajax({
            url : '/olt/new',
            type : 'POST',
            dateType : "json",
            data : $("#formId").serialize(),
            contextType : "application/x-www-form-urlencoded",
            success : function(data) {
              console.log("success");
            }
          });
        })
      });

      JSP,注意原生類型必須設(shè)置值:
      <form id="formId" method="get" action="" class="form-horizontal">
        <input type="hidden" name="id" value="0">
        <div class="form-group">
          <label class="col-sm-2 control-label">序列號</label>
          <div class="col-sm-10">
            <input type="text" name="oltSN" class="form-control">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">聯(lián)系人</label>
          <div class="col-sm-10">
            <input type="text" name="contact" class="form-control">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">手機(jī)</label>
          <div class="col-sm-4">
            <input type="text" name="mobile" class="form-control">
          </div>
          <label class="col-sm-2 control-label">電話</label>
          <div class="col-sm-4">
            <input type="text" name="tel" class="form-control">
          </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
          <label class="col-sm-2 control-label">板卡數(shù)</label>
          <div class="col-sm-4">
            <input type="text" name="cards" value="0" class="form-control">
          </div>
          <label class="col-sm-2 control-label">PON口數(shù)</label>
          <div class="col-sm-4">
            <input type="text" name="pons" value="0" class="form-control">
          </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
          <div class="col-sm-4 col-sm-offset-2">
            <button id="submitId" class="btn btn-primary">保存內(nèi)容</button>
            <button class="btn btn-white" type="submit">取消</button>
          </div>
        </div>
      </form>

      Spring的Controller,直接接受對象:
      @RequestMapping(value = "/new", method = RequestMethod.POST)
      @ResponseBody
      public Map newOlt(OltInfo o) {
        logger.info("newOlt..." + o);
        ……
      }



        本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約