Post提交带参网址

时间:2022-11-25 21:09:34

前端

$(function(){
var obj=$('#form1');
obj.validate({
submitHandler:
function (form){
var data={};
data.pupucode
="sdfdsfsf";
data.sign
="237";

var examData=JSON.stringify(data);
$.ajax({
contentType:
'application/json',
type :
"post",
url :
'checkpupu.cgi?access_token=0984E921-6AD5-43C6-AE26-E8261EC1FD48',
data:examData,
dataType :
'json',
success :
function(data) {
console.log(data);
}
});


}
});
})

后端

@RequestMapping(value="/checkpupu",method={RequestMethod.POST},consumes="application/json")
@ResponseBody
public JSONObject CheckPupuCode(@RequestBody JSONObject re,HttpServletRequest request) throws Exception{
JSONObject jsonobj
=new JSONObject();
JSONObject pupu
=JSONObject.fromObject(re);
try{
//凭证号
String access_token="0984E921-6AD5-43C6-AE26-E8261EC1FD48";
//凭证出错
if(!request.getParameter("access_token").equals(access_token)){

jsonobj.put(
"errcode", 403);
jsonobj.put(
"errmsg", "凭证出错");
return jsonobj;
}

String pupucode
=pupu.getString("pupucode");
String sign
=pupu.getString("sign");

String nhsign
=String.valueOf(Authority.checksign(pupucode));
//验签不成功!
if(!sign.equals(nhsign)){
jsonobj.put(
"errcode", 402);
jsonobj.put(
"errmsg", "验签不成功");
return jsonobj;
}

//码不存在的错误
WshopPupu wshoppupu=pupuservice.selectBypupucode(pupucode);
if(wshoppupu==null){
jsonobj.put(
"errcode", 401);
jsonobj.put(
"errmsg", "码不存在");
return jsonobj;
}
else {
if(wshoppupu.getTestcount()>=1){
jsonobj.put(
"errcode", 405);
jsonobj.put(
"errmsg", "码已经使用");
return jsonobj;
}
}

jsonobj.put(
"errcode", 0);
jsonobj.put(
"errmsg", "ok");
}
catch(Exception err){
err.printStackTrace();
}

return jsonobj;
}