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格式并提交给服务器的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。