记录:
网上有说怎么做,没说怎么接收,打印了一下数据,记录一下取值:
比如说有如下form:
<form id="form1" name="form1" action="" method="post">
<input type="hidden" name="submitTime" value="${now }">
<input type="hidden" name="receiverId" value="${receiverID }">
<input type="hidden" name="isRegister" value="${isRegister }">
</form>
发送异步请求提交form:
function save(){
$.ajax({
url:'debt/saveNew.do'+'?t='+Math.random(),
data:$('#form1').serialize(), //将表单数据序列化,格式为name=value
type:'POST',
dataType:'json',
success:function(data){
//success
},
error:function(){
console.log("提交ajax函数异常");
},
});
}
获取(能从param中取到值意味着怎么接收都可):
@RequestMapping(value = "saveNew")
//@Token(remove=true)
public void saveNew(
HttpServletRequest request,HttpServletResponse response){
response.setContentType("application/json; charset=UTF-8");
try {
String submitTime = request.getParameter("submitTime");
String receiverId = request.getParameter("receiverId");
String isRegister = request.getParameter("isRegister");