zoukankan      html  css  js  c++  java
  • jquery ajax 序列化表单传参提交实体对象到后台action

    ========action后台我这里使用的是SpringMVC如果用ssh用法一致===============

    @Controller
    @RequestMapping("PubjobController")
    public class PubjobController {
     @Autowired
     public PubjobServices pubjobServices;//业务层使用注解的方式

     //Pubjob  实体
     @RequestMapping("jobMgs")
     public String jobMgs(Pubjob job,HttpServletRequest request, HttpServletResponse response)
       throws IOException {
      System.out.print(job.getId());

      System.out.print(job.getName());   

      response.getWriter().write("操作成功!");


        response.getWriter().close();

      return null;
     }

    ===========js==============

    $.ajax({
        type : "POST",
        url : '/jubcrm/PubjobController/jobMgs.hml',
        data :  $("#frmjob").serialize(),//序列化表单提交input 值
        success : function(msg) {
      alert(msg);       

     }
         },
        error : function(msg) {
         $.messager.alert(prompts(), "操作失败");
        }
       });

    ==========jsp(input 的name必须和实体名称一致)==================

    <form method="post" id="frmjob" name="frmjob" action="">
        名称:<input type="text" name="name"  />      

        id:<input name="id" type="text" />

        </form>

  • 相关阅读:
    本周学习进度
    梦断代码阅读笔记01
    站立会议06(第二期)
    计算机软件方面的面试题?
    算法Bai-Piao
    哈希表
    关于编写代码的一些建议
    使用Promise
    Lintcode
    搭建Android浏览器壳子
  • 原文地址:https://www.cnblogs.com/qgc88/p/3363133.html
Copyright © 2011-2022 走看看