java - 转换 get 到 post http 方法
问题描述
我正在做简单的 api 任务,一切都很好。但我不会转换一些东西,我不知道怎么做!
@RequestMapping("/user/{id}")
public ResponseEntity<Users> getUserById(@PathVariable Integer id) {
return ResponseEntity.ok(userService.getUserById(id));
}
我想将此get方法转换为post方法,因此将id发送到body中然后获取结果。我怎样才能做到这一点?我可以这样登录吗?检查电子邮件和密码,如果它是真的然后重定向到另一个页面,或者有办法以最好的方式做到这一点?
解决方案
使用 value 和 method 属性将其转换为 post。
@RequestMapping("/user/{id}", method = RequestMethod.POST)
public ResponseEntity<Users> getUserById(@Param Integer id) {
return ResponseEntity.ok(userService.getUserById(id));
}
推荐阅读
- python - 如何从 Excel 创建一个字典,其中列表作为 Pandas 中的值?
- r - 安装 sdsMirco 时出错:在 pkg-config 搜索路径中找不到软件包 libcurl
- google-cloud-platform - 如果我不在 GCP 中支付账单,我可以将 bigquery 中的公共数据集下载到本地计算机吗?
- c - 如何在 C 中实现 Go 的 defer() 以便允许声明变量?
- javascript - Console log with color doesn't wrap first line
- antlr - How do I combine ANTLR lexer rules from different lexer grammars?
- android - Android Connection Service report outgoing call without showing native call UI?
- rapidminer - Can't start my RapidMiner without disabling extensions
- mysql - NodeJS with MySQL - Return blank Array
- javascript - 有没有办法在 Flask 中捕获没有 JavaScript 的 socket.io 事件?