1、jsp代码,form表单:
 <form action="#" id="costForm">
<input type="hidden" id="userId" name="userId"/>
<div id="COST">
<img src='<%=path %>/cvc/center/images/close.png' class="close" style="width:34px;position:absolute;right:0px;top:0px;"></img>
<h2 style="font-weight: bolder;font-size: 14px;">更改该注册订单的收费状态</h2>
<ul>
<li>
<label for="report">
 是否已报到:
</label>
<input type="radio" id="baodao1" name="baodao" value="1"/>是
<input type="radio" id="baodao0" name="baodao" value="0"/>否
</li> <li>
<label for="name">
  姓  名:
</label>
<span id="costName"></span>
</li> <li>
<label for="type">
  注册类型:
</label>
<span id="costType"></span>
</li>
<li>
<label for="sure_fee">
 在线支付手续费:
</label>
<span id="costType">0</span>
</li>
<li>
<label for="sure_fee">
  应收费金额:
</label>
<span id="price"></span>
</li> <li>
<label for="already_fee">
  已收费金额:
</label>
<input type="text" id="pay_" name="pay"/>
</li> <li>
<label for="owe">
  欠  款:
</label>
<span id="qianPay"></span>
</li> <li>
<label for="fee_type">
  付款方式:
</label>
<input type="radio" id="payType1" name="payType" value="3"/>银行
<input type="radio" id="payType2" name="payType" value="4"/>邮局
<input type="radio" id="payType3" name="payType" value="5"/>现金
<input type="radio" id="payType4" name="payType" value="2"/>在线支付
</li> <li>
<label for="fee_evidence">
是否收到汇款凭证:
</label>
<input type="radio" id="isReceiveProof1" name="isReceiveProof" value="1"/>是
<input type="radio" id="isReceiveProof0" name="isReceiveProof" value="0"/>否
</li> <li>
<label for="fa_piao">
  发票抬头:
</label>
<span id="billTitle"></span>
</li> <li>
<label for="fa_piao">
  发票编号:
</label>
<input type="text" id="billCode" name="billCode"/>
</li> <li>
<label for="check_evidence">
是否已开发票:
</label>
<input type="radio" id="isBill1" name="isBill" value="1"/>是
<input type="radio" id="isBill0" name="isBill" value="0"/>否
</li> <li>
<label for="get_evidence">
是否已领发票:
</label>
<input type="radio" id="isDrawBill1" name="isDrawBill" value="1"/>是
<input type="radio" id="isDrawBill0" name="isDrawBill" value="0"/>否
</li> <li> <label for="date">
已发确认日期:
</label>
<span id="confirmDate"></span>
<!-- <input type="text" id="confirmDate" name="confirmDate"/> -->
<!-- <input id="confirmDate" name="confirmDate" class="text" type="text" onClick="WdatePicker()"/> -->
</li>
<li>
<label for="check_letter">是否已发确认函:</label>
<span id="isConfirmInvitation"></span>
</li>
<li>
<label for="fa_piao">在线支付状态:</label>
<span id="payString"></span>
</li>
</ul>
<div class="fee_opr">
<button type="button" class="fee_sure" style="border: none;background: #003260;color: #ffffff;padding: 3px 30px;margin-left: 10px;border-radius: 0px;">确定</button>
<button type="button" class="fee_cancel" style="border: none;background: #003260;color: #ffffff;padding: 3px 30px;margin-left: 10px;border-radius: 0px;">关闭</button>
</div>
</div>
</form>
2、js代码:
  $(".fee_sure").click(function () {
var dataObj = $("#costForm").serialize();
var payType = $('input[name="payType"]:checked').val();
if(payType == undefined){
alert("请选择付款类型");
return ;
}else{
$.ajax({
url:"/webCenter.do?method=saveUserMessage",
type: "post",
dataType:"json",
data:dataObj,
cache:false,
ifModified:true,
success:function(json){
if(json.flag == 1){
alert("1234");
}
}
})
}
})

3、后台action处理:

     @RequestMapping(params ="method=saveUserMessage",method=RequestMethod.POST)     //导入发言
public void saveUserMessage(int userId,HttpServletRequest request,HttpServletResponse response){
try {
HttpSession session = this.getSession(request);
Adminuser adminUser = session.getAttribute("centerAdminUser") == null?null:(Adminuser) session.getAttribute("centerAdminUser");
if(adminUser == null){
try {
response.sendRedirect(request.getContextPath()+"/center/index.jsp");
} catch (Exception e) {
e.printStackTrace();
}
}else{
String billNumber = request.getParameter("billCode")==null?"":request.getParameter("billCode");
String isBaodao = request.getParameter("baodao")==null?"0":request.getParameter("baodao");
String haspay = request.getParameter("pay")==null?"0":request.getParameter("pay");
String payType = request.getParameter("payType")==null?"0":request.getParameter("payType");
String isFkpz = request.getParameter("isReceiveProof")==null?"0":request.getParameter("isReceiveProof");
String isYkfp = request.getParameter("isBill")==null?"0":request.getParameter("isBill");
String isYlfp = request.getParameter("isDrawBill")==null?"0":request.getParameter("isDrawBill");
JSONObject jsonObject = new JSONObject();
//AdminuserConferences adminuserConferences = webService.getAdminuserConferences(adminUser.getAdminuserId());
UserInfo userInfo = webService.getUserInfoById(userId);
if(userInfo!=null)
{
jsonObject.accumulate("flag",1);
ChcRegUser chcRegUser = webService.getChcRegUser(userId);
if(chcRegUser!=null)
{
chcRegUser.setHasPay(Integer.parseInt(haspay));
chcRegUser.setPayType(Integer.parseInt(payType));
if(chcRegUser.getHasPay()-chcRegUser.getPay()==0)
{
chcRegUser.setStateType(1);
}
webService.saveObject(chcRegUser);
userInfo.setIsBaodao(Integer.parseInt(isBaodao));
userInfo.setIsFkpz(Integer.parseInt(isFkpz));
userInfo.setBillNumber(billNumber);
userInfo.setIsYlfp(Integer.parseInt(isYlfp));
userInfo.setIsYkfp(Integer.parseInt(isYkfp));
webService.saveObject(userInfo);
jsonObject.accumulate("pay", chcRegUser.getPay());
jsonObject.accumulate("haspay", chcRegUser.getHasPay());
}
}else {
jsonObject.accumulate("flag",0);
}
writeJson(response, jsonObject.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}

form表单数据封装成json格式并提交给服务器的更多相关文章

  1. <form> 标签 // HTML 表单 // from 表单转换成json 格式

    <form> 标签   // HTML 表单    // from 表单转换成json 格式 form 表单,对开发人员来说是在熟悉不过的了,它是页面与web服务器交互时的重要信息来源 表 ...

  2. jquery自动将form表单封装成json的具体实现

    前端页面:<span style="font-size:14px;"> <form action="" method="post&q ...

  3. form表单序列化为json格式数据

    在web开发过程中,经常遇到将form序列化不能格式的字符串提交到后台,下面就介绍怎样将form表单序列化为json字符串. 首先,是扩展的jquery序列化插件,依赖jquery.经测试,这段代码可 ...

  4. 表单数据转换成json格式数据

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  5. 通过jquery的serializearray处理表单数据成json格式,并提交到后台处理

    var params = $("#myform").serializeArray(); var values = {}; for (var item in params) { va ...

  6. JQuery将form表单值转换成json字符串函数

    由于后台接口限定,必须要将表单内容转换成json字符串提交,因此写了一个将form表单值转成json字符串的函数.     前提:页面引入了JQuery          下面直接上代码 一.代码 / ...

  7. 关于AJAX与form表单提交数据的格式

    一 form表单传输文件的格式: 只有三种: multipart/form-data 一般用于传输文件,图片文件或者其他的. 那么其中我们默认的是application/x-www-form-urle ...

  8. 把表单转成json,并且name为key,value为值

    http://jsfiddle.net/sxGtM/3/http://stackoverflow.com/questions/1184624/convert-form-data-to-js-objec ...

  9. 表单配置项写法,表单写成JSON数组套对象,一行是一个数组单位,一列是一个对象单位,然后再写一个公共组件读取这个配置,循环加载slot,外层载入slot的自定义部分,比如input select等,这种写法就是把组件嵌套改为配置方式

    表单配置项写法,表单写成JSON数组套对象,一行是一个数组单位,一列是一个对象单位,然后再写一个公共组件读取这个配置,循环加载slot,外层载入slot的自定义部分,比如input select等,这 ...

随机推荐

  1. SQL数据查询语句(一)

    本文所用数据库为db_Test,数据表为Employee 一.SELECT语句基本结构 语句语法简单归纳为: SELECT select_list [INTO new_table_name] [FRO ...

  2. 博客迁移至 http://www.loveli.site

    对于博客园的Markdow 支持太过...,你懂的,  以后博客迁移至:http://www.loveli.site

  3. Java基础笔记2

    1.   变量的定义 int money; int 变量类型   money 变量名 money=1000;变量的值 2.  自动类型转换 ①类型要兼容  容器 (水杯---竹篮---碗) ②目标类型 ...

  4. 微信小程序用setData修改数组或对象中的一个属性值

    在page中有如下数组 data: { info:[ { name:"yuki", tou:"../img/head.jpg", zGong:130, gMon ...

  5. js让input失去焦点

    要求:当我点击页面非文本框的地方,令文本框失去焦点 问题:一开始我的做法是让点击的地方得到焦点,实际上是无效的 $(this).focus(); 当时我也不知道为什么focus会失效,   问题在于f ...

  6. 对Numpy广播操作的理解

    1.首先检查两个矩阵维数是否相同,若不同,对维数少的补一.注意这里的维数不是指n行d列中的n和d的值,对于这种情况维数就是2.若一个两维的矩阵(n,d)和一个一维的数组(m,)相乘,补一操作就是将那个 ...

  7. Python 抽象篇:面向对象之类的方法与属性

    概览:类成员之字段:-普通字段,保存在对象中,执行职能通过对象访问-静态字段,保存在类中,执行可以通过对象访问,也可以通过类访问类成员之方法:-普通方法,保存在类中,由对象来调用,self->对 ...

  8. VS2008 C++ 利用WinHttp API获取任意Http网址的源码

    最近一直在看有关Http的知识,对其基本的理论知识已经有所掌握,想通过一个C++具体的例子进行实际操作..于是上网查找了很多资料,发现在Windows系统上,可以通过WinHttp API接口开啊Ht ...

  9. echarts2.2.7本地搭建

    1.首先下载echarts2.2.7,解压到本地,解压后的目录如下: 2.在WebContent下建立一个名为build的目录,复制echarts2.2.7下面的build下面的dist目录到ecli ...

  10. Android 开发笔记___SQLite__基本用法

    SQLiteOpenHelper package com.example.alimjan.hello_world.dataBase; import android.content.ContentVal ...