首页 > 解决方案 > 如何将 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]

标签: javaspringspring-boot

解决方案


推荐阅读