//前端页面

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Axios的post请求方式</title>
<!--引入axios的相关依赖-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<input type="text" >//后端代码
@PostMapping("save")
@CrossOrigin//跨域
public Map<String,Object> save(String name,Integer age){
System.out.println("name ="+name);
System.out.println("age="+age);
Map<String, Object> map=new HashMap<>();
map.put("success",true);
map.put("message","保存成功");
return map;
}

相关文章: