java - 如何将 id 放入重定向(@PutMapping)
问题描述
当用户更新数据时,我想重定向到/post/
用户的 ID。但以下代码不起作用。
@PutMapping("/post/edit/{id}")
public String update(@PathVariable("id") Long id , @RequestBody BoardDto boardDto) {
boardService.savePost(boardDto);
return "redirect:/post/" + id;
}
@PathVariable("id") Long id
@PathVariable Long id
@PathVariable String id
Whiteable
页面错误也弹出
WARN 12524 --- [nio-8080-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported]
解决方案
推荐阅读
- kubernetes - 如何将 Kubernetes DiskPressure 状态从 true 更改为 false?
- linux - 通过忽略文件名中第一个空格后的所有内容来重命名文件
- asp.net-web-api - 在 .NET Standard Web Api 中使用 Serilog 将关联 ID 添加到 Seq
- java - 从java下载可执行文件
- java - Java 14 的 Affinity.jar
- android - 如何在 Android 的 WorkManager 中执行挂起/排队的工作
- c# - 查找具有公差的唯一对象列表
- node.js - 我只是想使用 mediasoup npm 但不知道如何记录来自 mediasoup npm 的流/对话
- python - 当有时间跳跃时,在时间戳索引上拆分 DF
- python-3.x - 如何比较两个字典列表?