jquery.form.js+springboot

不多说,上代码

服务器端

public class StringModel {
    private String string1;
    private String string2;
    private String string3;
    private String string4;}
省略get/set


@RequestMapping(value = "/findStrings", method = RequestMethod.POST)
public StringModel  findStrings(@ModelAttribute StringModel stringModel){
    System.out.println(stringModel.toString());
    return null;
}

html,这是一个前后端分离,支持跨域的项目,所以里面用的是JSONP,如果一个项目下dataType:json 

<!DOCTYPE html>
<html>


<head>
<meta charset="UTF-8">
<title></title>
<script src="../js-business/jquery-3.1.1.min.js"></script>
<script src="../js-business/jquery.form.js"></script>
<script>
$(document).ready(function() {
$("#btnButton").click(function() {
var options = {
contentType: "application/x-www-form-urlencoded; charset=utf-8",
url: 'http://192.168.1.104:8760/test/findStrings',
type: 'post',
dataType: "json",
jsonp: "jsoncallback",
success: function(data) {

}
};
$("#ajaxForm").ajaxSubmit(options);
return false;
});
});

</script>
</head>


<body>
<form id="ajaxForm" method="post">
<input class="mui-input-clear" type="text" placeholder="string1" id="string1" name="string1">
<input class="mui-input-clear" type="text" placeholder="string2" id="string2" name="string2">
<input class="mui-input-clear" type="text" placeholder="string3" id="string3" name="string3">
<input class="mui-input-clear" type="text" placeholder="string4" id="string4" name="string4">
</form>
<button id="btnButton" type="button">提交2</button>
</body>
</html>



测试结果





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值