springboot 参数传递(表单序列化)
**************************
示例
****************
前端页面
<script language="JavaScript" src="/jquery/jquery-3.4.1.min.js"></script>
<script>
$(function () {
$("button").click(function () {
$.post({
url: "/hello5",
data: $("form").serialize()
})
})
})
</script>
<body>
<form th:align="center">
name: <input name="name"><br>
age: <input name="age"><br>
<button>提交</button>
</form>
</body>
****************
controller 层
HelloController
@RestController
public class HelloController {
@RequestMapping("/hello5")
public String hello5(Person person){
System.out.println(person);
return "success";
}
}
**************************
使用测试
单击button,控制台输出
Person(name=瓜田李下, age=20)