post请求 ssm
时间: 2023-11-30 20:42:10 浏览: 39
以下是一个使用SSM框架进行POST请求的例子:
```java
// 后端的接受参数(SSM)
@RequestMapping(value = "/postRequest", method = RequestMethod.POST)
@ResponseBody
public ResponseData postRequest(HttpServletRequest request, @RequestParam("param1") String param1, @RequestParam("param2") String param2) {
// 处理POST请求的逻辑
// ...
return responseData;
}
```
以下是一个使用axios库进行POST请求的例子:
```javascript
// 前端的POST请求(使用axios库)
import axios from 'axios';
import qs from 'qs';
const data = {
param1: 'value1',
param2: 'value2'
};
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
axios.post('/postRequest', qs.stringify(data), { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
```